append 和appendTo ,appendChild,insertBefore实例

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

  <style type="text/css">
  body {
	font-family: "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
	font-size: 62.5%;
}
</style>
  <script>
  $(function() {
  //$(selector).append(content,function(index,html))
 // append     //jQuery
 // appendTo    //jQuery
 // appendChild   //DOM
  //node.insertBefore(newnode,existingnode)   //DOM  
	//$(content).insertBefore(selector)// //jQuery
	//$(content).prependTo(selector)//jQuery

   debugger
	$("button").append(" <b>ooo</b>");//jQuery
	$("button").append("ooo");//jQuery
	//prependTo() 方法在被选元素的开头插入 HTML 元素。
	$("<span>1w</span>").appendTo("button");//jQuery
	var chl	=$("[name=divame]").children().last().children().first();
	$("<li>cccuuu</li>").insertBefore(chl);//jQuery

	
	var nodechild=document.getElementById("w1").lastChild;
	var node2 =document.getElementById("w2");
	node2.appendChild(nodechild);//DOM
	node2.insertBefore(nodechild,node2.firstChild);//DOM
	var kl = document.createElement("li");
	$(kl).append("ofijio");
	node2.insertBefore(kl,node2.firstChild);
	$("<li>liushahe</li>").insertBefore($(node2.firstChild));///
	
	var node=document.getElementById("myList2").lastChild;
	var list=document.getElementById("myList1");
	list.insertBefore(node,list.childNodes[0]);

		var txt1="<p>Text.</p>";              // Create text with HTML
		var txt2=$("<p></p>").text("Text.");  // Create text with jQuery
		var txt3=document.createElement("p");
		txt3.innerHTML="Text.";               // Create text with DOM
		$("body").append(txt1,txt2,txt3);        // Append new elements
	
	
	po=document.createElement("LI");
    $(po).append("kuuu");
    node2.appendChild(po);//po : <li>kuuu</li>
  });
function mydetails()
{
var x = document.createElement("DETAILS");
var t = document.createTextNode("Some additional details...");
x.appendChild(t);
document.body.appendChild(x);


}
  function mydivtwi()
	{
	var node=document.getElementById("myList2").lastChild;
	document.getElementById("myList1").appendChild(node);
	}
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker"></p>
 <p>Date: <input type="text" id="date"></p>
 <div><button> 确定</button></div>

<div name="divame">

<ul id="w1"><li>huang</li><li>shan</li></ul>
<ul id="w2"><li>zhu</li><li>hai</li></ul>
</div>
<div name="divtwi">
<ul id="myList1"><li>Coffee</li><li>Tea</li></ul>
<ul id="myList2"><li>Water</li><li>Milk</li></ul>
<button οnclick="mydivtwi()">亲自试一试</button>

</div>
<h3>演示如何访问 DETAILS 元素</h3>

<p>点击按钮来创建 DETAILS 元素。</p>

<button οnclick="mydetails()">试一下</button>

</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值