How do change iframe url on click menu links?

We can change the source url for an iframe on any page, when you click on menu items, then iframe source url will be changed, So add the class change on meuu links an click on menu handler also so that it will remove the onSelect class from the previous element and will add the onSelect class by jquery.

Page link on click to change iframe url through jquery

This is custom code for iframe url change onclick to any menu links, Use this below iframe url base code for condition match url change iframe source url on click jquery.

Here is html code:

<div id="menu">
<ul>
<a class="test" target='playframe' href="a.html">A</a>
<a class="test" target='playframe' href="b.html">b</a>
<a class="test" target='playframe' href="c.html">c</a>
</ul>
</div>
<iframe name='playframe' id="iframe"></iframe>


Here is jquery script code:

<script>
$(function () {
var $content = $('#iframe');
$('#menu a')
.click(function () {
$content.attr('src', $(this).attr('href'));
$('#menu a.test').removeClass('test').addClass('Offselect');
$(this).addClass('test').removeClass('Offselect');
return false;
});
});
</script>

Post a Comment

0 Comments