简体   繁体   中英

jquery select link by name

i can reference link with specific id with following code

 $(document).ready(function(){
       $("a#example_link_id").click(function(event){
         var url = $(this).attr("href");
          get_uid(url);
         //event.preventDefault();

       });
  });

is it possible to use $("a#example_link_id") this by link name

Your selector(s) can include specific attributes as well. For example:

$("a[name='foo']");

Which would select

<a href="foo.html" name="foo">Foo</a>

For more information, http://api.jquery.com/category/selectors/

you might be looking for this:

var $link = $("a[name=some_name]");

where some_name is the value of the name attribute of the link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM