html - Change image using jQuery -
i have html-page used jquery-ui accordion. have add in page 2 image should vary depending on active section. how can it?
html:
<div id="acc"> <h1>something</h1> <div>text text text</div> <h1>something too</h1> <div>text2 text2 text2</div> </div> <div id="pic"> <img class="change" src="1.png"/> <img class="change" src="2.png"/> </div>
js:
$(document).ready(function() { $("#acc").accordion({ change: function(event, ui) { /* i'm think need here */ } }); });
this script show first img first panel, second img second panel , on
jquery(function($) { $("#acc").accordion({ change: function(event, ui) { var index = $(ui.newcontent).index("#acc>div"); $("#pic .change") // hide .hide() // find right image .eq(index) // display image .show(); } }); });
Comments
Post a Comment