[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how do you toggle multiple images

Posted on 2014-01-24
2
Medium Priority
?
178 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

834 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