jQuery_API_05_Manipulation

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

<!DOCTYPE html PUBLIC "-//W<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="author" content="马永占(MyZ)" />

<meta name="Copyright" content="马永占(MyZ)" />

<meta name="description" content="" />

<meta name="keywords"content="" />

<link rel="icon" href="" type="image/x-icon" />

<link rel="shortcut icon" href="" type="image/x-icon" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

<style type="text/css">

</style>

<script type="text/javascript" src="jquery-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.6</chsdate>.js"></script>

</head>

<body>

<script type="text/javascript">

$("document").ready(function(){

////////////////////////////////////////////////////////////////////////////////////////

//Changing Contents:

//html( ) Returns: String

//Get the html contents (innerHTML) of the first matched element. This property is not available on XML documents (although it will work for XHTML documents).

// $("p").click(function () {

// var htmlStr = $(this).html();

// $(this).text(htmlStr);

// });

//html( val ) Returns: jQuery

//Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents).

//$("div").html("<span class='red'>Hello <b>Again</b></span>");

//text( ) Returns: String

//Get the combined text contents of all matched elements.

// var str = $("p:first").text();

// $("p:last").html(str);

//text( val ) Returns: jQuery

//Set the text contents of all matched elements.

//$("p").text("<b>Some</b> new text.");

////////////////////////////////////////////////////////////////////////////////////////

//Inserting Inside:

//append( content ) Returns: jQuery

//Append content to the inside of every matched element.

//$("p").append("<b>Hello</b>");

//appendTo( selector ) Returns: jQuery

//Append all of the matched elements to another, specified, set of elements.

//$("span").appendTo("#foo"); // check append() examples

//prepend( content ) Returns: jQuery

//Prepend content to the inside of every matched element.

//$("p").prepend("<b>Hello </b>");

//prependTo( selector ) Returns: jQuery

//Prepend all of the matched elements to another, specified, set of elements.

//$("span").prependTo("#foo"); // check prepend() examples

////////////////////////////////////////////////////////////////////////////////////////

//Inserting Outside:

//after( content ) Returns: jQuery

//Insert content after each of the matched elements.

//$("p").after("<b>Hello</b>");

//before( content ) Returns: jQuery

//Insert content before each of the matched elements.

//$("p").before("<b>Hello</b>");

//insertAfter( content ) Returns: jQuery

//Insert all of the matched elements after another, specified, set of elements.

//$("p").insertAfter("#foo"); // check after() examples

//insertBefore( content ) Returns: jQuery

//Insert all of the matched elements before another, specified, set of elements.

//$("p").insertBefore("#foo"); // check before() examples

////////////////////////////////////////////////////////////////////////////////////////

//Inserting Around:

//wrap( html ) Returns: jQuery

//Wrap each matched element with the specified HTML content.

//$("p").wrap("<div></div>");

//wrap( elem ) Returns: jQuery

//Wrap each matched element with the specified element.

//$("p").wrap(document.createElement("div"));

//wrapAll( html ) Returns: jQuery

//Wrap all the elements in the matched set into a single wrapper element.

//$("p").wrapAll("<div></div>");

//wrapAll( elem ) Returns: jQuery

//Wrap all the elements in the matched set into a single wrapper element.

//$("p").wrapAll(document.createElement("div"));

//wrapInner( html ) Returns: jQuery

//Wrap the inner child contents of each matched element (including text nodes) with an HTML structure.

//$("p").wrapInner("<b></b>");

//wrapInner( elem ) Returns: jQuery

//Wrap the inner child contents of each matched element (including text nodes) with a DOM element.

//$("p").wrapInner(document.createElement("b"));

////////////////////////////////////////////////////////////////////////////////////////

//Replacing:

//replaceWith( content ) Returns: jQuery

//Replaces all matched elements with the specified HTML or DOM elements. This returns the JQuery element that was just replaced, which has been removed from the DOM.

// $("button").click(function () {

// $(this).replaceWith("<div>" + $(this).text() + "</div>");

// });

//replaceAll( selector ) Returns: jQuery

//Replaces the elements matched by the specified selector with the matched elements.

//$("<b>Paragraph. </b>").replaceAll("p"); // check replaceWith() examples

////////////////////////////////////////////////////////////////////////////////////////

//Removing:

//empty( ) Returns: jQuery

//Remove all child nodes from the set of matched elements.

// $("button").click(function () {

// $("p").empty();

// });

//remove( expr ) Returns: jQuery

//Removes all matched elements from the DOM.

// $("button").click(function () {

// $("p").remove();

// });

////////////////////////////////////////////////////////////////////////////////////////

//Copying:

//clone( ) Returns: jQuery

//Clone matched DOM Elements and select the clones.

//$("b").clone().prependTo("p");

//clone( true ) Returns: jQuery

//Clone matched DOM Elements, and all their event handlers, and select the clones.

// $("button").click(function(){

// $(this).clone(true).insertAfter(this);

// });

////////////////////////////////////////////////////////////////////////////////////////

});

</script>

</body>

</html>

你可能感兴趣的:(JavaScript,html,jquery,XHTML,Office)