我正在尝试制作一个按钮,以便在按下时将一个 div 滑开,然后将另一个 div 滑回,但是我试图阻止它刷新页面,但是
return false;
行似乎破坏了脚本。有任何想法吗?
HTML:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="slide.js"></script>
</head>
<body>
<button id="button1" onclick="nextSlide('#1', '#2')">Hide it</button>
<p id="1">Hide this text</p>
<p id="2">Show this text</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
</body>
</html>
JS:
window.onload=function(){
$('#2').fadeOut(1);
};
function nextSlide(hideDiv, showDiv) {
$(hideDiv).hide("slide", 2000, function(){
$(showDiv).show("slide", 2000);
});
return false;
};