zoukankan      html  css  js  c++  java
  • jquery----->helloworld

    <html>
    <head>
    <title>first jquery</title>
    
    <script type="text/javascript" src="jquery-1.7.2.js"></script>
    <script type="text/javascript">
        
        //$(function(){}) 相当于 window.onload, 代码卸载 {} 之间
        $(function(){
            //1. 选取 button: $("button")
            //2. 为 button 添加 onclick 响应函数: $("button").click(function(){})
            //代码编写在 function 的 {} 中. 
            $("button").click(function(){
                //3. 弹出 helloworld
                alert("helloworld");
            });
        })
    
    </script>
    </head>
    <body>
        <button id="button">ClickMe</button>
    </body>
    </html>

    jQuery对象就是通过jQuery($())包装DOM对象后产生的对象。

    var $variable=jQuery对象

    var variable=DOM对象

    由于jQuery对象是一个数组对象。所以可以根据下标转换成DOM对象。

    alert($btn[0].firstChild.nodeValue);

    由DOM对象转换成jQuery对象。使用$()包装

    alert($(btn).text())

  • 相关阅读:
    等价表达式
    读入字符串
    n以内质数占的比例
    图论——最小生成树_prim
    搜索
    图论——最小生成树
    线段树模板
    WC总结
    三练斜率优化
    斜率优化技巧——换个角度思考
  • 原文地址:https://www.cnblogs.com/bulrush/p/5793623.html
Copyright © 2011-2022 走看看