?
Solved

how do you toggle multiple images

Posted on 2014-01-24
2
Medium Priority
?
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

771 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