Solved

how do you toggle multiple images

Posted on 2014-01-24
2
161 Views
Last Modified: 2014-01-24
Hi,

I have a table with some images that I would like to be able to toggle.  The trick is that when one is in the "on" state the others should be in the "off" state.

Here is the table :
<table cellspacing="7" cellpadding="0" border="0">
	<tr>
	    <td width="60" align="left">View:</td>
	    <td width="100"align="left"><a class="showAllTypes" style="cursor:pointer;"><img src="images/allTypes.png" />All Types</a></td>
	    <td width="113" align="left"><a class="showOnDemand" style="cursor:pointer;"><img src ="images/onDemand.png">On Demand</a></td>
		<td width="101" align="left"><a class="showWebinars" style="cursor:pointer;"><img src ="images/Webinars.png">Webinars</a></td>
		<td width="141" align="left"><a class="showSeminars" style="cursor:pointer;"><img src ="images/seminars.png"> Seminars</a></td>
        </tr>
        </table>

Open in new window


Just have no idea how to write the function so all the images know that when one is clicked the others will be in the off state.

Thanks,
allTypes.png
allTypesChecked.png
onDemand.png
onDemandChecked.png
seminars.png
seminarsChecked.png
webinars.png
webinarsChecked.png
0
Comment
Question by:smfmetro10
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39807362
Try this

$("a").click(function(){
    $("a img").each(function(){
      $(this).attr("src",$(this).attr("src").replace("Checked.png",".png"))
    })
    $("img",this).attr("src",$("img",this).attr("src").replace(".png","Checked.png"))
})

Open in new window

0
 

Author Closing Comment

by:smfmetro10
ID: 39807443
Yahoo!!!! Thanks!!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question