Solved

how do you toggle multiple images

Posted on 2014-01-24
2
160 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now