X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=57915bf117ea68964b5fe483e891db29facd8643;hb=2abe5934f6793606c8717b6282f54d7eca1bd42c;hp=358c165469761c5603fa560b7b7393791c8c3ced;hpb=232da5dde03ae774980c9800950e60f3f4468c68;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 358c165..57915bf 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -487,7 +487,27 @@ jQuery.fn = jQuery.prototype = { * @type String * @cat DOM */ + + /** + * Set the text contents of all matched elements. This has the same + * effect as calling .html() with your specified string. + * + * @example $("p").text("Some new text."); + * @before

Test Paragraph.

+ * @result

Some new text.

+ * + * @param String val The text value to set the contents of the element to. + * + * @name text + * @type String + * @cat DOM + */ text: function(e) { + // A surprisingly high number of people expect the + // .text() method to do this, so lets do it! + if ( typeof e == "string" ) + return this.html( e ); + e = e || this; var t = ""; for ( var j = 0; j < e.length; j++ ) { @@ -2602,6 +2622,7 @@ jQuery.macros = { /** * Get the html contents of the first matched element. + * This property is not available on XML documents. * * @example $("div").html(); * @before
@@ -2614,6 +2635,7 @@ jQuery.macros = { /** * Set the html contents of every matched element. + * This property is not available on XML documents. * * @example $("div").html("new stuff"); * @before