我的HTML代碼在這裏如何使用ATTR
<i id="bgcolor" style="background-color: rgb(255, 146, 180)"></i>
我想使用jQuery ATTR
獲得背景色值我想什麼是波紋管
$("#bgcolor").mouseleave(function(){
var bodyColor = $(this).attr("style");
$("body").css(bodyColor);
});
但是這個輸出是
background-color: rgb(255, 146, 180);
和我被添加到.css它不會工作。我如何實現這個任務?
是否有你想用'attr()'而不是'css()'獲取樣式的原因? – 2013-05-14 17:22:17
參考http://api.jquery.com/css/。你會得到解決方案:) – 2013-05-14 17:26:16