使用jquery添加css规则 [英] add css rule using jquery
本文介绍了使用jquery添加css规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像这样的CSS规则:
#imgwrapper {display:block; position:relative; width:auto; height:auto;}
所以我得到一个超链接,当它被点击,它应该添加一个css规则到#imgwrapper像这样:
#imgtarget,#imgwrapper img {cursor:crosshair;}
我应该怎么办?
我试过jquery .css api but it aint working ..
解决方案$('a.whatever' );
$('#imgwrapper img')。 b $ b});
i got a css rule like this:
#imgwrapper {display: block;position: relative;width:auto;height:auto;}
so i got a hyperlink that when it's clicked, it should add a css rule to #imgwrapper like this:
#imgtarget, #imgwrapper img {cursor:crosshair;}
how should i do it??
i tried jquery .css() api but it aint working..
解决方案See the $.css() function
$('a.whatever').click(function() { $('#imgtarget').css('cursor' , 'crosshair'); $('#imgwrapper img').css('cursor', 'crosshair'); });
这篇关于使用jquery添加css规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文