Solved

how do you toggle multiple images

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

743 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

12 Experts available now in Live!

Get 1:1 Help Now