如何获取css按钮以保持活动后,它被点击? [英] How to get css button to stay active after it has been clicked?
本文介绍了如何获取css按钮以保持活动后,它被点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要制作导航栏,一旦用户点击图片,图片就会保持活动状态。在以下示例中,单击后叶子将保持绿色。这里有一些代码我在说什么:
Im trying to make a nav bar where once the user clicks on the image, the image stays active. In the following example the leaf would stay green after is is clicked. Here is a bit of code of what Im talking about:
<a class="myButtonLink" href="#LinkURL">Leaf</a>
<style>
.myButtonLink {
display: block;
width: 100px;
height: 100px;
background: url('http://kyleschaeffer.com/wordpress/wp-content/uploads/2009/01/buttonleafhover.png') bottom;
text-indent: -99999px;
}
.myButtonLink:hover {
background-position: 0 0;
}
</style>
推荐答案
http://jsfiddle.net/bnaegele/XHBZf/2/
$('.myButtonLink').click(function() {
$(this).css('background-position', '0 0');
});
这篇关于如何获取css按钮以保持活动后,它被点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文