为什么jquery方法addClass()不起作用? [英] Why jquery method addClass() is not working?

查看:602
本文介绍了为什么jquery方法addClass()不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>


<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

<style type="text/css">

.abc
{
    background-color:green;
    font-size:200%;
}

.red
{
    background-color:red;
    font-size:200%;
}



</style>
<body>

<p class="abc">ABC</p>



</body>


<script type="text/javascript">


$(document).ready(function(){
  $(".abc").mouseenter(function(){
    $(".abc").css("background-color","yellow");
  });
  $("p").mouseleave(function(){
    $("p").addClass("red");
  });
});

</script>



</html>

推荐答案

document )。ready( function (){
(document).ready(function(){


。abc)。mouseenter( function (){
(".abc").mouseenter(function(){


。 abc)。css( background-color 黄色);
});
(".abc").css("background-color","yellow"); });


这篇关于为什么jquery方法addClass()不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆