Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts

    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(); 

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,677
    Thanks
    6
    Thanked 1,008 Times in 981 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •