is there a way, with jquery, to for exapmle on click, find all iframe elements, remove their src= tag, and give it back? sort of, refresh :)
Was looking for foreach function or something like that, but I'M rather hopeless at this :(
Thanks for your time, Mart
$(document).ready(function() {
$('#somebuttonid').click(function() {
$("iframe").each(function() {
var src = $(this).attr('src');
$(this).attr('src', src);
});
});
});
You can refresh all the iframe like this
$("iframe").each(function() {
$(this).attr('src', $(this).attr('src'));
});
You can pass a function to .attr()
[docs] (or .prop()
[docs]):
$('iframe').attr('src', function(index, val) {
return val;
});
This function is executed for each element. It's a bit more concise than using an explicit .each
loop.
You don't even need jQuery:
for(var i = 0; i < frames.length; i++) {
frames[i].src = frames[i].src;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With