1.自动触发事件

<!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>
    <style type="text/css">
    .Red
    {
     color:Red;
    }
     .Green
    {
     color:Green;
    }
    .buttons
    {
        text-align:center;
        font-weight:bold;
        border:2 solid;
        width:100px;
        float:left;
        margin:5px;
        background-color:Gray;
    }
    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $('.buttons').bind('click', function () {
                 alert('you click' + $(this).text());
                  $('.Green').trigger('click');
             });


         });
     </script>
</head>
<body>

<span class="Red buttons">Red</span>
<span class="Green buttons">Green</span>

<p></p>
  

</body>
</html>

2.点击之后禁用按钮

<!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>
    <style type="text/css">
    .Red
    {
     color:Red;
    }
     .Green
    {
     color:Green;
    }
    .buttons
    {
        text-align:center;
        font-weight:bold;
        border:2 solid;
        width:100px;
        float:left;
        margin:5px;
        background-color:Gray;
    }
    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $('.buttons').bind('click', function () {
                 alert('you click' + $(this).text());
                 $('.buttons').unbind('click');
             });


         });
     </script>
</head>
<body>

<span class="Red buttons">Red</span>
<span class="Green buttons">Green</span>

<p></p>
  

</body>
</html>

3.处理鼠标事件(鼠标点击,释放,划过)

<!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>
    <style type="text/css">
    .Red
    {
     color:Red;
    }
     .Green
    {
     color:Green;
    }
    .buttons
    {
        text-align:center;
        font-weight:bold;
        border:2 solid;
        width:100px;
        float:left;
        margin:5px;
        background-color:Gray;
    }
    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $('.buttons').bind('mousedown', function () {
                 alert('you mouse button is pressed down' + $(this).text());

             });

             $('.buttons').bind('mouseup', function () {
                 alert('The mouse button is released over'+$(this).text());
             });

             $('.buttons').bind('mouseover', function () {
                 alert('The mouse button is over' + $(this).text());
             });


         });
     </script>
</head>
<body>

<span class="Red buttons">Red</span>
<span class="Green buttons">Green</span>

<p></p>
  

</body>
</html>

4.元素获得,失去焦点

<!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>
    <style type="text/css">

    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $("#Name").focus(function () {
                 alert('Name has been focused');
             }
             );

             $("#Name").blur(function () {
                 alert('Name lost focus');
             });
         });
     </script>
</head>
<body>

   Name <input id="Name" type="text" />
<p></p>
  

</body>
</html>

5.应用悬停效果

<!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>
    <style type="text/css">
    .buttons
    {
        text-align:center;
        font-weight:bold;
        border:2 solid;
        width:100px;
        float:left;
        margin:5px;
        background-color:Gray;
    }
    .hover
    {
     cursor:crosshair;
     color:Blue;    
     background-color:cyan;
    }
    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
          //把两个事件处理程序添加到指定的元素,一个用于当鼠标进入元素时触发,
         //一个用于鼠标离开触发
             $('.buttons').hover(
             function () {
                 $(this).addClass("hover");
             },
             function () {
                 $(this).removeClass("hover");
             }
             );

         });
     </script>
</head>
<body>
<span class="buttons">Click</span>
</body>
</html>

6.'更多'连接

<!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>
    <style type="text/css">
    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $('#Message').hide();
             $("#more").toggle(
             function () {
                 $("#Message").show('slow');
                 $(this).text('read less');
             },
             function () {
                 $('#Message').hide();
                 $(this).text('Read More');
             }
             )
         });
     </script>
</head>
<body>
<div>Welome to My Blog</div>
<span id="more">Click More</span>
<div id="Message">
I'm a software engineer development,i have been work in shanghai for about 6 months.I love this job.
it got a lot of potential than my old job.In order to Earning money,I need to work hard and contribute to my team.
</div>
</body>
</html>

7.以滑动效果替换文本

<!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>
    <style type="text/css">
    </style>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $('#message1').css({ 'backgroundColor': '#f00', 'text-align': 'center','width':'200px' }).hide();
             $("#message2").css({ 'backgroundColor': 'gray', 'text-align': 'center','width': '200px' }).click(function () {
                 $(this).slideUp();
                 $("#message1").slideDown();
             });
         });
     </script>
</head>
<body>
<p id="message1">Welome to My Blog</p>

<p id="message2">Welcome to My Facebook</p>
</body>
</html>

8.滚动效果

更多相关文章

  1. 在PHP中获取幕布元素ID的文本[重复]
  2. 使用jQuery随机化一系列div元素
  3. AngularJS使用双向数据绑定将img元素标签中的图像显示为源?
  4. html5中点击按钮,改变按钮状态效果样式
  5. 选择父母没有某个类的所有元素(使用'.not()')
  6. 是否可以将HTML元素固定到另一个的底部?
  7. 如何根据容器更改元素的宽度?
  8. 通过属性名称获取HTML元素
  9. Jquery在两个元素之间更改文本

随机推荐

  1. jquery 添加transform样式
  2. Ajaxify在Ruby on Rails 4上的评论发布和
  3. 不玩Android的jQuery jPlayer。
  4. 关于js 方法,实现ajax请求时,return fals
  5. 如何在MVC4中使用type= " url "而不用jQu
  6. jquery.min.js引入项目报错
  7. JQuery攻略(三)数组与字符串
  8. jsf中获取属性值的普通获取和jquery获取
  9. jQuery中filter()和find()的区别深入了解
  10. 有关下拉框jquery里的change事件无法触发