jQuery object equality

前端 未结 7 1828
醉梦人生
醉梦人生 2020-11-22 14:37

How do I determine if two jQuery objects are equal? I would like to be able to search an array for a particular jQuery object.

$.inArray(jqobj, my_array);//-         


        
7条回答
  •  执念已碎
    2020-11-22 14:53

    If you still don't know, you can get back the original object by:

    alert($("#deviceTypeRoot")[0] == $("#deviceTypeRoot")[0]); //True
    alert($("#deviceTypeRoot")[0] === $("#deviceTypeRoot")[0]);//True
    

    because $("#deviceTypeRoot") also returns an array of objects which the selector has selected.

提交回复
热议问题