2014-09-27 27 views
-1

我寫了一個簡單的jQuery代碼,用於將按鈕的div移動到右側。我已經寫了jQuery代碼,因爲這是這裏的代碼:SyntaxError:missing}在jQuery代碼執行的屬性列表顯示後

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=windows-1250"> 
<meta name="generator" content="PSPad editor, www.pspad.com"> 
<title></title> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
<script> 

$(document).ready(function() { 
    $('#leftscroll').click(function() { 
     $('#buttonmove').animate({'marginLeft' : '+= 30px' 
    )};      

)};   
)}; 
</script> 
<style> 
.button{ 
width:100px; 
height:100px;} 

div #buttonmove{ 
float:left; 
margin: auto 0; 
position:absolute; 
} 
</style> 
</head> 
<body> 
<div> 
    <a id="leftscroll" href="#">>></a></div> 
    <div id="buttonmove"> 
    <button type="button" id="button">Click Me!</button> 
    <button type="button" id="button">Click Me!</button> 
    <button type="button" id="button">Click Me!</button> 
    <button type="button">Click Me!</button> 
</div> 
<div class="preyear"> 
    <a id="rightscroll" href="#"><<</a> 
</div> 
</body> 
</html> 

當我執行此代碼,這是不執行,並顯示錯誤

請幫我...

回答

2

糾正你的括號如下圖所示:

$(document).ready(function() { 
    $('#leftscroll').click(function() { 
     $('#buttonmove').animate({ 
     'marginLeft' : '+= 30px' 
     });  //<----- here     
    });  //<----- here    
});  //<----- here 
+0

@ user3785854 ...我想以上答案將解決您的問題,如果需要更多的幫助,然後評論。 – 2014-09-27 08:15:14

相關問題