Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2009, 10:34 PM   PM User | #1
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
outline 1 element only

Hi all i have the following code.

Code:
$(document).ready(function(){
		$("ul, li, a, p, img").hover(
			function(){
				var origBorder = $(this).css("border");
				var elementID = $(this).attr("id");
				$(this).css("possition", "absolute").css("z-index", "100").css("border", "1px solid red");
			}, 
			function(){
				$(this).css("border", "none").css("z-index", "1");	
			}
		);
	});
it is suposed to outline the element that i am hovering over. Yet if I hover over say an <li> it will outline the li and the ul. Any ideas on how to just outline the element im hovering over?
__________________
Website Design Mansfield
PHP Code:
function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
echo 
I_LOVE(); 
Phil Jackson is offline   Reply With Quote
Old 12-07-2009, 10:57 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,600
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by Phil Jackson View Post
it is suposed to outline the element that i am hovering over. Yet if I hover over say an <li> it will outline the li and the ul. Any ideas on how to just outline the element im hovering over?
Well, list items can only be children of list elements so if you specify ul in the selectors of course it will also apply to the list of which the lis are children. What happens if you remove the ul selector from the function? Would that matter?

And on another note: You shouldn’t mix CSS with JS just as you shouldn’t mix CSS or JS with HTML with HTML. Better way would be to add a class to a certain element and write the styles applying to elements with that class in the stylesheet.

And for the records: In css("possition", "absolute") it should read “position” with single “s” only.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:53 AM.


Advertisement
Log in to turn off these ads.