zoukankan      html  css  js  c++  java
  • jQuery HTML-设置

    例子1

    html

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<title>jquery</title>
    		<script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
    		<script type="text/javascript" src="js/try.js" ></script>
    	</head>
    	<body>
    		<p id="p1">hello world</p>
    		<button id="btn1">点我</button>
    	</body>
    </html>
    

      js

    $(document).ready(function(){
    	$("#btn1").click(function() {
    		$("#p1").text("世界和平");
    		
      });
    });
    

     效果:

     例子2

    html

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<title>jquery</title>
    		<script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
    		<script type="text/javascript" src="js/try.js" ></script>
    	</head>
    	<body>
    		<button id="btn1">点我</button>
    		<button id="btn2">点我</button>
    	     <p id="p1">hello world</p>
    		   <p id="p2">are you ok</p>
    	</body>
    </html>
    

      js

    $(document).ready(function(){
    	$("#btn1").click(function() {
    		$("#p1").text("世界和平");
    		
      });
      $("#btn2").click(function() {
    		$("#p2").html("<a hre='#'>天气好好</a>");
    		
      });
    });
    

      效果:

    例子3

    html

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<title>jquery</title>
    		<script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
    		<script type="text/javascript" src="js/try.js" ></script>
    	</head>
    	<body>
    		<button id="btn3">点击</button>
    		<input type="text" id="input"  value="hello world"> 
    	</body>
    </html>
    

      js

    $(document).ready(function(){
    
      $("#btn3").click(function(){
        $("#input").val("世界和平");
        
       
      });
    });
    

      效果:

    例子4

    html

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<title>jquery</title>
    		<script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
    		<script type="text/javascript" src="js/try.js" ></script>
    	</head>
    	<body>
    		<button id="btn1">跳转</button>
    		<a   id="a"  href="http://www.baidu.com">百度网站,点击改变</a>
    	</body>
    </html>
    

      js

    $(document).ready(function(){
    
      $("#btn1").click(function(){
        $("#a").attr("href","http://www.jquery123.com");
        
     });
    });
    

      效果:

  • 相关阅读:
    HDU 3833 YY's new problem ()
    从文件读入16进制数转化为10进制数再输出到文件中
    UESTC 1215 (思维题 旋转)
    HDU2067卡特兰数
    HDU2050离散数学折线分割平面
    cshell学习
    C++学习1
    QT学习1
    QT Creator常用快捷键
    Ubuntu14.04安装QT5.5
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/7569572.html
Copyright © 2011-2022 走看看