<!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>
append 和appendTo ,appendChild,insertBefore实例
最新推荐文章于 2024-07-28 20:27:10 发布