标签:string roo 指定 中间 cli 元素 var bsp otc
1 $("ul li").each(function(index,value){ 2 alert(index+":"+$("value").html()); 3 }) 4 5 6 7 $.each($("ul li"),function(index,value){ 8 alert(index + ":"+$(value).html()); 9 })
1 一、load() 2 3 1.获取信息(只关心内容,不限制格式) 4 $("#btn").click(function(){ 5 $("#box").load("abc.txt"); //url 必写 6 }) 7 8 2.获取其他页面的内容及样式 9 $("#btn").click(function(){ 10 $("#box").load("info.html",function(){ 11 $(".zzl").click(function(){ 12 alert($(this).html()) 13 }) 14 }) 15 }) 16 17 二、$ajax ---- 获取php 18 19 $("#btn").click(function(){ 20 $.ajax({ 21 type:"get", 22 url:"demo.php", 23 async:true, 24 data:"user=狗子&pwd=123", 25 success:function(data){ 26 alert(data); 27 }, 28 dataType:"html" 29 }); 30 })
三、GET
1 1.获取页面 2 3 $("#btn").click(function(){ 4 $.get("memo.html",function(responese){ 5 $("#box").html(responese); 6 }) 7 }) //获取页面中的内容 8 9 2.获取php 10 11 $("#btn").click(function(){ 12 $.get("demo.php?name=张志林&pwd=zzl123",function(responese){ 13 alert(responese); 14 $("#box").html(responese); 15 }) 16 }) //PHP所有内容 17 18 3.map格式 19 20 $("#btn").click(function(){ 21 $.get("demo.php",{ 22 name:"张志林", 23 pwd:"zzl123" 24 },function(response){ 25 alert(response); 26 $("#box").html(response) 27 }) 28 }) //PHP所有内容 29 30 4.string 31 $("#btn").click(function(){ 32 $.get("demo.php","name=张志林&pwd=zzl123",function(response){ 33 alert(response); //php所有内容 34 $("#box").html(response); 35 }) 36 }) 37 38 5.访问xml文件 39 $("#btn").click(function(){ 40 $.get("demo.xml",function(responese){ 41 alert(responese); //[object XMLDocument] 42 var data =$(responese).find("root").find("user").html(); 43 alert(typeof data); //string 44 var arr = data.split(":"); 45 alert(arr[0]+"----"+arr[1]) //获得下标0-1中间的内容 46 }) 47 })
四、get json
1 $("#btn").click(function(){ 2 $.get("demo.json",function(response){ 3 //alert(response) //json 所有内容 4 $("#box").append($("<h2>"+response[0].user+":"+response[0].pwd+"</h2>")) //json内容部分 5 }) 6 })
var $div = $(“<div>是DOM</div>”)
$(“body”).append($div)
var $div = $("<div title=‘div盒子’>我是DOM</div>") $("body").append($div);
标签:string roo 指定 中间 cli 元素 var bsp otc
原文地址:http://www.cnblogs.com/Makeprogresstogether/p/8011460.html