Splitting A Single Value
I have: and when I do: var Y = $('td').data('X'); Z=Y.split(); it works. But if I have: then it doesn't work. At least I think that
Solution 1:
I wonder if it's being interpreted as an integer instead of a string. Try Z = Y.toString( ).split( )
Solution 2:
.data()
is smart. It tries to use a more appropriate type than string
for the value - in your case, it's number
.
From the docs:
Every attempt is made to convert the string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null) otherwise it is left as a string. To retrieve the value's attribute as a string without any attempt to convert it, use the attr() method.
Post a Comment for "Splitting A Single Value"