+ -
当前位置:首页 → 问答吧 → 运行书<jQuery基础教程>中的例子出现错误。 Thank you.

运行书<jQuery基础教程>中的例子出现错误。 Thank you.

时间:2010-03-28

来源:互联网

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/jquery.js" type="text/javascript"></script>
    <link href="../Chapter%204/gettysburg.css" rel="stylesheet" type="text/css" />
</head>
<body>
      <div id="switcher">
        <div class="label">Sytle Switcher</div>
        <div class="button" id="switcher-large">Increase Text Size</div>
        <div class="button" id="switcher-small">Decrease Text Size</div>
      </div>
     
      <div class="speech">
 
         <p>Fourscore and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. <span class="more">. . .</span></p>
        <p>Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting-place for those who here gave their lives that the nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallow, this ground. </p>
       
          <p>The brave men, living and dead, who struggled here have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember, what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.</p>
        <p>It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom and that government of the people, by the people, for the people, shall not perish from the earth.</p>
     
      </div>
      <script type="text/javascript" language="javascript">
      $(document).ready(function() {
        $('div .label').click(function() {
          $('div.button').animate({left:650, height:38}, 'slow');
        });
     
      });
         
      </script>
     
</body>
</html>
-----------------------------------------------.css----------------------------------------
.hover{
  cursor: pointer;
  background: #ffc;
}
#switcher {
  position: relative;
}
.label {
  width: 130px;
}
.button {
  width: 140px;
  padding: 5px;
  margin: .5em 0;
  border: 1px solid #e3e3e3;
  position: relative;
}
#brave {
  position: relative;
}
------------------------------------运行错误--------------------------
单击<div class="label">Sytle Switcher</div>
IE调试器显示:
fx: function( elem, options, prop ){
  var z = this;
  // The styles
  var y = elem.style;
  
  if ( prop == "height" || prop == "width" ) {
   // Store display property
   var oldDisplay = jQuery.css(elem, "display");
   // Make sure that nothing sneaks out
   var oldOverflow = y.overflow;
   y.overflow = "hidden";
  }
  // Simple function for setting a style value
  z.a = function(){
   if ( options.step )
    options.step.apply( elem, [ z.now ] );
   if ( prop == "opacity" )
    jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
   else {
    y[prop] = parseInt(z.now) + "px";    //无效参数
    y.display = "block"; // Set display property to block for animation
   }
  };

作者: john2006   发布时间: 2010-03-28

IE不支持~~换成firefox就行了

作者: margina   发布时间: 2010-04-08