jquery CSS方法获取不带单位的属性值
1、首先定义一个 div
<div></div>
2、然后设置样式
<style> div { width: 100px; height: 100px; } </style>
3、引入jQuery
<script src="path/to/jquery.min.js"></script>
4、使用jquery的css方法获取元素的宽度
var h = $('div').css('width'); console.log(h); //100px
5、获取的值是带单位的,使用parseInt方法去除单位即可
var nopx = parseInt(h); console.log(nopx);//100