jQuery如何获取元素的属性值的内容呢,一起看下例子:
下面的例子获取div中 style 属性的内容。
<script type="text/javascript">
$(function(){
$(".show").each(function(i){
var v = $(this).attr("style");
alert(v);
});
});
</script>
<div class="show" style=" font-size:14px; color:#03C;">test1</div>
<div class="show" style=" font-size:16px; color:#009;">test2</div>
<div class="show" style=" font-size:18px; color:#000;">test3</div>