1、Get the attribute, check the value

var attr = $(this).attr('name');

// For some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
if (typeof attr !== typeof undefined && attr !== false) {
  // Element has this attribute
}

2、Native JavaScript has a way

$(this)[0].hasAttribute("name");

jQObject[0].hasAttribute("name");

3、Filter the selection

$(this).is('[name]');

$(this).filter("[name='choice']");

 

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2021-11-02
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2022-02-28
猜你喜欢
  • 2022-12-23
  • 2022-01-27
  • 2021-11-07
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案