jQuery滑動並響應事件


jQuery滑動並打開指定頁面:

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script> 
$(document).ready(function(){
  $(".a").click(function(){
    $(".a").animate({left:'250px'},function(){location.href="http://www.baidu.com"});
  });
});
</script> 
</head>
 
<body>
<p>默認情況下,所有 HTML 元素的位置都是靜態的,並且無法移動。如需對位置進行操作,記得首先把元

素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p>
<h3>點擊方塊執行</h3>
<div class='a' style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>

</body>
</html>
View Code

jQuery來回滑動並響應事件:

<!DOCTYPE html>
<html>
<head>
<script src="jquery/jquery.js">
</script>
<script> 
$(document).ready(function(){
  $("#box").toggle(function(){
    $("#box").animate({left:'200px'},function(){alert('Slide to the right');}).text('ON');},
    function(){
    $("#box").animate({left:''},function(){alert('Sliding to the left');}).text('OFF');}
  );
});
</script> 
</head>

<body>
<p>默認情況下,所有 HTML 元素的位置都是靜態的,並且無法移動。如需對位置進行操作,記得首先把元素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p>
<h3>點擊方塊執行</h3>
<div id='box' style="background:#98bf21;height:100px;width:100px;position:absolute;">OFF
</div>

</body>
</html>
View Code

 jQuery下載:http://files.cnblogs.com/liuswi/jquery.js


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM