jQuery: Find the element with a particular custom attribute

后端 未结 4 1900
误落风尘
误落风尘 2021-02-05 01:32

I just want to find the element with a particular value for a custom attribute.

E.g. I want to find a the div which has the attribute data-divNumber=\

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 02:03

    var number = 6;
    var myDiv = $('div[data-divNumber="' + number + '"]');
    

提交回复
热议问题