Unable to set number in .data() method
I am trying to set a number as my data type dynamically using .data()
method in jQuery, but so far no luck. This works using the .attr() method
as I have listed in below. Why does the .data() method not work with
numbers?
var container = $(this).find('#container'); // element which should have
the data
Attempt 1:
container.data(24, "opacity:0;");
Attempt 2:
container.data("24", "opacity:0;");
The following code works using .attr():
container.attr("data-123", 1223);
No comments:
Post a Comment