在jQuery中查找具有特定属性值的所有元素 [英] Find all elements with a certain attribute value in jquery

查看:112
本文介绍了在jQuery中查找具有特定属性值的所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到所有具有特殊属性值的元素.

I need to find all elements that has a special attribute value.

这是我需要查找的div(我有很多.)

Here is the div I need to find (I have many of them..)

<div imageId='imageN'>...

我只需要遍历具有imageId='imageN'

推荐答案

$('div[imageId="imageN"]').each(function() {
    // `this` is the div
});

要检查属性的唯一存在,无论使用哪个值,都可以使用选择器代替:$('div[imageId]')

To check for the sole existence of the attribute, no matter which value, you could use ths selector instead: $('div[imageId]')

这篇关于在jQuery中查找具有特定属性值的所有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆