2016-02-29 45 views
1

我只是测试了jQuery,这可能很简单,但我试图找出这里有什么问题。为什么不是这个jQuery脚本工作?我看不到任何错

我只是想让按钮稍微淡入淡出。

$(document).ready(function(){ 
 
\t $('button').mouseenter({ 
 
\t \t $('button').fadeTo('slow',1); 
 
\t }}; 
 
});
button { 
 
\t border:2px solid #27ae60; 
 
\t border-radius:5px; 
 
\t height:50px; 
 
\t width:125px;; 
 
\t background-color:#2ecc71; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <meta charset="UTF-8"> 
 
    <title>title</title> 
 
    </head> 
 
    <body> 
 
    
 
    <button>Click Me</button> 
 

 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> 
 
    </body> 
 
</html>

谢谢!

+2

你褪色为1的不透明度,这是一些语法问题它现在是。 –

+0

语法错误,即使固定不透明也会阻止任何工作:'}};'脚本代码段的第4行中的'应该是'});' – dasjanik

回答

2

您的按钮目前的不透明度为1,而您的淡入淡出效果不会改变该效果。你也有一些错误的大括号。像这样的东西会工作:

$(document).ready(function(){ 
    $('button').on('mouseenter', function(){ 
     $('button').fadeTo('slow',0); 
    }); 
}); 

看到它在这里工作:https://jsfiddle.net/0Lqcnbv5/

希望帮助!

0

我得到了你的使用工作下面

$(document).ready(function(){ 
 
\t 
 
\t $("#button").mouseenter(function() { 
 
\t \t $(this).fadeTo("slow", 0.33); 
 
\t }); 
 
\t 
 
});
button { 
 
\t border:2px solid #27ae60; 
 
\t border-radius:5px; 
 
\t height:50px; 
 
\t width:125px;; 
 
\t background-color:#2ecc71; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <meta charset="UTF-8"> 
 
    <title>title</title> 
 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> 
 

 
    </head> 
 
    
 
    <body> 
 
    
 
    <button id="button">Click Me</button> 
 

 
    </body> 
 
    
 
</html>

有与jQuery的

相关问题