Attempted to retrieve atriboot of an element using the .attr function. I dynamically assign values to the class attribute using an input element.
$ ('item-select-zodiac'). Click (function () {console.log ($ (this) .attr ('class'));}; This will return:
item-selection-amount ui-corner-all-price-item-selection-amount ui-corner-all 66.00 < / Code Value is always different, but is it possible to draw the third value of the class attribute such as attr ('class [2]') << P> You are using the class attribute incorrect .
Intend to use for visual presentation. What do you want to do
For that purpose, you html5 Data - attributes : $ ('item-selection-amount'). Data ('price', 66.00); // ... later $ ('item-select-amount'). Click (function () {console.log ($ (this) .data ('value'));}; If you want to add value to the element, then just present the HTML as the following on the server:
& lt; Li class = 'item-selection-item' data-value = '66.00 '& gt; Some & lt; / Li & gt;
Comments
Post a Comment