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开发者_StackOverflow社区 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
精彩评论