I have this code which loads and display’s iframe which is display:hidden in default:
$("div").on('click', '.blok', function () {
$(this).siblings("iframe").toggle().show().attr("src", $(this).siblings('span').find('a').attr('href') );
});
As you can see I have put .toggle so that a second click would restore to default values. The problem is that the second click also LOADS the iframe again (while it is hidden). What can I do to load only once in the toggle event?
the attr(‘src’..) should only be called once (or every time you want to load the page)
i’d leave the toggle there but put the attr outside the function