Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 13th Nov 2013, 12:40 AM   #1
HyperActive Warrior
 
Join Date: 2011
Posts: 101
Thanks: 27
Thanked 1 Time in 1 Post
Default
How to change two different images on one click
Share on: 
fb share twitter share gplus share more share

Hi Everyone,

I'm trying to create a landing page that has two images, and if you select one, it will turn on a highlight around it.

Then if you select the other, it will turn off the highlight from the first one, and turn on the highlight for the one most recently selected. (and then toggle the highlighting if you click back to the first image)

I don't know if this matters, but my page is using php, but I'm very new to it, and to css.

Can anyone get me pointed in the right direction?

Thanks in advance!

- Pete

Interested in Psychic Development? You've never seen anything like Miracle Mastery. Take a look!
TinPete is offline  
Unread 13th Nov 2013, 08:43 AM   #2
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: How to change two different images on one click
Share on: 
fb share twitter share gplus share more share

Pretty simple job with jQuery. Just add the following code to the <head> section (assuming you are using HTML5)...

HTML Code:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

<script>    
   $(document).ready(function() {
       $('img').click(function(){ // when an image is clicked...
           $('img').css('border', ''); // first remove the border from all images        
           $(this).css('border', '2px solid yellow'); // then add a border to selected image
       });
   }); 
</script>
^ That will give the selected image a 2px solid yellow border. You can of course change the border color, width, etc. to whatever you want.


Brandon Tanner is offline  
The Following 2 Users Say Thank You to Brandon Tanner For This Useful Post:
Unread 15th Nov 2013, 11:14 PM   #3
HyperActive Warrior
 
Join Date: 2011
Posts: 101
Thanks: 27
Thanked 1 Time in 1 Post
Default
Re: How to change two different images on one click
Share on: 
fb share twitter share gplus share more share

Thanks! That's just what I was looking for!

Interested in Psychic Development? You've never seen anything like Miracle Mastery. Take a look!
TinPete is offline  
Closed Thread


Bookmarks

Tags
change, click, images


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 08:44 PM.