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())

  • 相关阅读:
    MySQl的绑定变量特性
    数数 / DP
    MODE
    题单
    对拍
    二、图论
    sync_with_stdio(false)的副作用
    九大编程语言
    Codeforces Round #575 (Div. 3) A B C
    Educational Codeforces Round 69 (Rated for Div. 2) A B C D
  • 原文地址:https://www.cnblogs.com/bulrush/p/5793623.html
Copyright © 2011-2022 走看看