I have the following code:
alert($embellishment.data("embellishmentId"));
alert($embellishment.attr("data-embellishmentId"));
The first alert returns undefined
, whereas the second alert returns an integer, 3
.
-- SEE DEMO --
I'm using jQuery version 1.7.2 (data
was added with version 1.4 I believe)
Why is this? Should I be using data()
at all if its not returning the right values?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…