which method is fast and safe to get data- attribtes value
hi
i can get the data attribute using following pls tel me which one is fast and safe .
specally i want to know that the jquery method the third one will tervers the whole dom to find the element or
it will just convert the element's object into jquery and would get the data- attributes vlaue?
the obj is a variable where i have passed the this key word
onclick="fun(this.getAttribute('data-uid')
and inside function fun i have used all three ways to get the value of data-uid
1)
var
uid
=
obj
.
getAttribute
(
'data-uid'
)
2)
var
uid
=
obj
.getAttribute('data-uid')
3)
var
uid
=
$
(
obj
).
attr
(
'data-uid'
);