简体   繁体   English

在jquery中通过除id(即,href标记)以外的其他方式标识DOM

[英]Identifying a DOM by something other than id (ie: it's href tag) in jquery

The title covers most of my question. 标题涵盖了我的大部分问题。 Instead of: 代替:

$('#id').slideUp();

I need to be able to select a particular area tag in an image map in a similar way, by virtue of the string in its href tag. 我需要能够通过其href标签中的字符串以类似的方式在图像地图中选择特定的区域标签。 I'm sure this involves the .attr() function but in what way I don't know. 我确定这涉及到.attr()函数,但是我不知道以哪种方式。
Could a resident genius help me please. 一位天才居民能帮我吗。 Many thanks. 非常感谢。

$('[href="something"]').slideUp();

您可以在http://docs.jquery.com/Selectors/attributeHas#attribute上了解其他属性过滤器

签出属性选择器

$("[href='whatever']").slideUp();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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