jquery问题求解释在线等
[code=HTML][/code]
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(".left").click(function(){
if ( $("div").hasClass("protected") )
$(this).animate({ left: -10});
});
</script>
<style type="text/css">
.protected {font-style:italic;}
</style>
</head>
<body>
<div class="protected">ddddd</div><div></div>
<button id="left">«</button> <button id="right">»</button>
</body>
</html>
问下问什么我的div没有变化求解释刚接触jquery
[解决办法]
$("#left")
[解决办法]
$(document).ready(function(){ $("div").click(function(){ if ( $(this).hasClass("protected") ) $(this).animate({height:300},"slow"); .animate({width:300},"slow"); .animate({height:100},"slow"); .animate({width:100},"slow"); });});
[解决办法]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("div").click(function(){ if($(this).hasClass("protected")) { $(this).animate({ height: 300 }, "slow").animate({ width: 300 }, "slow").animate({height:100},"slow").animate({ width: 100 }, "slow"); } });}); </script> <style type="text/css"> .protected { background: #98bf21; height: 100px; width: 100px; position: relative; } </style></head><body> <div id="box" class="protected"> </div> <div>dddd</div></body></html>