April 23, 2012

finding all iframe srcs with jquery

Question by Martin

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

Answer by ubercooluk

  $(document).ready(function(){ 
$('#somebuttonid').click(function(){
$("iframe").each(function() { 
        var src= $(this).attr('src');
        $(this).attr('src',src);  
});

    });
});

Answer by Starx

You can refresh all the iframe like this

$("iframe").each(function() { 
   $(this).attr('src', $(this).attr('src')); 
});

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!