【问题标题】:In jQuery how do I find elements if they contain the attribute, regardless of its value? [duplicate]在 jQuery 中,如果元素包含属性,无论其值如何,我如何找到它们? [复制]
【发布时间】:2020-06-28 20:11:21
【问题描述】:

在 jQuery 中,我可以像这样查找具有特定数据属性值的元素...

$(myElt).find(`[data-slide='${current}']`)

但是我将如何根据元素是否包含“data-slide”属性来查找元素,而不管“data-slide”值设置为什么?

【问题讨论】:

标签: jquery jquery-selectors custom-data-attribute


【解决方案1】:

你可以写:

$(myElt).find(`[data-slide]`);

【讨论】:

  • 这是一个经常重复重复的问题,无需回答,只需找到dupetarget即可。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-12
  • 1970-01-01
  • 2018-01-25
  • 2012-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多