zoukankan      html  css  js  c++  java
  • jQuery:1.[34],jQuery基础学习(二)

    ylbtech-jQuery:jQuery学习
    jQuery:1.3.1,改变HTML元素内容返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
      $("p").html("W3School");
      });
    });
    </script>
    </head>
    
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">请点击这里</button>
    </body>
    
    </html>
    jQuery:1.3.2,向HTML元素追加内容返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
      $("p").append(" <b>W3School</b>.");
      });
    });
    </script>
    </head>
    
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">请点击这里</button>
    </body>
    
    </html>
    jQuery:1.3.3,在HTML元素之后追加内容 返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
      $("p").after(" W3School.");
      });
    });
    </script>
    </head>
    
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">请点击这里</button>
    </body>
    
    </html>
    jQuery:1.4.1,改变HTML元素的CSS属性返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
      $("p").html("W3School");
      });
    });
    </script>
    </head>
    
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">请点击这里</button>
    </body>
    
    </html>
    jQuery:1.4.2,改变多个CSS属性返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        $("p").css({"background-color":"red","font-size":"200%"});
      });
    });
    </script>
    </head>
    
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">Click me</button>
    </body>
    
    </html>
    jQuery:1.4.3,获得元素的CSS属性返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("div").click(function(){
      $("#result").html($(this).css("background-color"));
      });
    });
    </script>
    </head>
    
    <body>
    <div style="100px;height:100px;
    background:#ff0000"></div>
    <p id="result">Click in the box</p>
    </body>
    </html>
    jQuery:1.5.1,使用 $(selector).load(url) 来改变 HTML 内返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("#b01").click(function(){
      $('#myDiv').load('jquery/test1.txt');
      });
    });
    </script>
    </head>
    <body>
    
    <div id="myDiv"><h2>通过 AJAX 改变文本</h2></div>
    <button id="b01" type="button">改变内容</button>
    
    </body>
    </html>
    jQuery:1.5.2,使用 $.ajax(options) 来改变 HTML 内容 返回顶部
    <html>
    <head>
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("#b01").click(function(){
      htmlobj=$.ajax({url:"jquery/test1.txt",async:false});
      $("#myDiv").html(htmlobj.responseText);
      });
    });
    </script>
    </head>
    <body>
    
    <div id="myDiv"><h2>通过 AJAX 改变文本</h2></div>
    <button id="b01" type="button">改变内容</button>
    
    </body>
    </html>
    warn 作者:ylbtech
    出处:http://ylbtech.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    编码转换,基础补充,深浅拷贝,id is == ,代码块(了解),小数据池(了解)
    字典(dict),字典的嵌套,集合(set)
    列表,列表的增删改查,列表的嵌套,range
    整数,布尔值,字符串,字符串详解.
    [小明学Shader]4.自定义光照----RampTexture
    [小明学Shader]3.自定义光照,半拉姆伯特
    [小明学Shader]2.理解Shader和Material的关系
    [小明学Shader]1.Diffuse
    [UGUI]你说UnityEngine.UI.Button是怎么通过拖动来增加OnClick的监听器的呢?
    [小明也得懂架构]1.架构初探
  • 原文地址:https://www.cnblogs.com/ylbtech/p/2859052.html
Copyright © 2011-2022 走看看