Jquery 更改动画元素的css

Jquery 更改动画元素的css,jquery,css,Jquery,Css,我想淡入一个(按钮)图像到另一个。 有两个固定css类: .btn{ background: url(../images/btn.png) no-repeat 0 0; text-decoration: none; height: 45px; width: 245px; margin:0; border: 0; overflow: hidden; cursor: pointer; /* hand-shaped cursor */ padding: 0 10px 0 10px; text-alig

我想淡入一个(按钮)图像到另一个。 有两个固定css类:

.btn{
background: url(../images/btn.png) no-repeat 0 0;
text-decoration: none;
height: 45px;
width: 245px;
margin:0;
border: 0;
overflow: hidden;
cursor: pointer; /* hand-shaped cursor */
padding: 0 10px 0 10px;
text-align: left;
font-weight: bold;
}
.btn_hover{
border: 0;
background: url(../images/btn.png) no-repeat 0 -45px;
text-decoration: none;
height: 45px;
width: 245px;
overflow: hidden;
cursor: pointer; /* hand-shaped cursor */
padding: 0 10px 0 10px;
text-align: left;
font-weight: bold;
}
是否有jquery命令来执行此操作?(只需将.btn动画设置为.btn_悬停) 谢谢

我已经厌倦了使用答案,但不起作用:

$("#button").bind("mouseover, mouseout", function() {
    $("#button" ).switchClass( "btn", "btn_hover", 1000 );
});
如果要将一个(背景)图像淡入另一个区域,则必须使另一个元素(例如,在父对象中)的状态与要淡入的状态相同,并将其不透明度设置为0。然后显示它-将其不透明度设置为1。


<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('#submit').hover(
            function(){ 
                $(this).attr({ "style" : "background:url('enter_over.gif');"});
            },
            function(){
                $(this).attr({ "style" : "background:url('enter.gif');"});             }
        );
    });
</script>
$(文档).ready(函数(){ $(“#提交”)。悬停( 函数(){ $(this.attr({“style”:“background:url('enter_over.gif');”); }, 函数(){ $(this.attr({“style”:“background:url('enter.gif');”});} ); });

请参阅:

如果您愿意使用jQueryUI,它提供了一个可以实现这一点的工具。如果这是您唯一想要的,您可能可以从jQuery UI中提取它。

您应该指定这是jQuery uionmouseout,我必须中断此过程。有什么方法可以做到这一点吗?但是op样式表中唯一改变的值是
背景图像。你不能给它设置动画。您的代码只是延迟了:hover伪类不适用于?在我的例子中,它是一个。它也可以用于输入标签。。请参阅参考链接
$("#button").bind("mouseover, mouseout", function() {
$( "#effect" ).toggleClass( "newClass", 1000 );
            return false;
});
<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('#submit').hover(
            function(){ 
                $(this).attr({ "style" : "background:url('enter_over.gif');"});
            },
            function(){
                $(this).attr({ "style" : "background:url('enter.gif');"});             }
        );
    });
</script>