Simple Help

Discussion in 'jQuery' started by bsdus, Aug 26, 2011.

  1. #1
    
    $('#target').click(function() {   alert('Handler for .click() called.'); }); 
    Code (markup):
    I want #target = all <a href=""> links

    How to.. example, after click any a href link = alert..:)

    This is, thanks
     
    bsdus, Aug 26, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Instead of '#target', use 'a'. (Links [anchors] are 'a'.)
     
    Rukbat, Aug 26, 2011 IP
  3. bsdus

    bsdus Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <script>
    $('a:link').click(function() {   alert('Handler for .click() called.'); });
    </script>
    
    <a href="#test">Test</a>
    
    Code (markup):
    No working;
     
    bsdus, Aug 26, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    If you want only the ones with an href, you could use $("[href]")

    If you only want those with a link of #test, use $("[href='#test']")
     
    Rukbat, Aug 26, 2011 IP