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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts

    how can i do this selection in jquery

    i want to select the div with id headerimg, so this is:
    Code:
         jQuery("div#headerimg").click(function () {
       
           document.location="http://google.com/";
        });
    but at the same time i want to omit a table with id=search_form from the selection.
    thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    And the search_form table is inside the headerimg div I suppose?

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    yes it is

  • #4
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Try the following code;
    Code:
    $('#headerimg').click(function(event){
      var $target = $(event.target);
    
      // Stop it from executing for search form and children
      if ($target.is('#search_form') == true || $target.parents('#search_form').length > 0)
      {
        return;
      }
    });
    And yes I know I could cut down the code, but I chose not to for readability


  •  

    Posting Permissions

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