Home>Article>Web Front-end> How to get attribute value without unit in jquery css
jquery css method to get attribute values without units: first define a div; then set the style and introduce jQuery; then use the jquery css method to get the width of the element; finally use the parseInt method to remove the unit .
The operating environment of this tutorial: windows7 system, jquery1.10.0&&css3 version. This method is suitable for all brands of computers.
Recommended: "css video tutorial"
jquery css method to obtain attribute values without units
1. First Define a div
2, then set the style
3, introduce jQuery
4, use jquery’s css method to get the width of the element
var h = $('div').css('width'); console.log(h); //100px
5. The obtained value has a unit. Use the parseInt method to remove the unit.
var nopx = parseInt(h); console.log(nopx);//100
The above is the detailed content of How to get attribute value without unit in jquery css. For more information, please follow other related articles on the PHP Chinese website!