I have some javascript code that shows and hides a div when I click an image. The issue that I am having is that that the text next to the picture will not cause the same operation. The layout is (picture) text. The picture is an arrow and changes to an arrow of different orientation when it is clicked to represent expansion. Here is the javascript and HTML code.
HTML Code:<img class="show" src="arrow_right.png" /><span>Text 1</span> <div class="toggle">Expanded text 1</div>All I need is for the text to have the same effect as the pictureCode:<script> $(document).ready(function(){ $('.toggle').hide(); $('.show').click(function(){ var t = $(this); // toggle hidden div t.next().next().toggle('slow', function(){ // determine which image to use if hidden div is hidden after the toggling is done var imgsrc = ($(this).is(':hidden')) ? 'arrow_right.png' : 'arrow_down.png'; // update image src t.attr('src', imgsrc ); }); }) }) </script>


Reply With Quote
Bookmarks