jquery: parseHTML(...) added. #421

This commit is contained in:
Diullei Gomes
2013-03-26 10:18:02 -03:00
parent 8737e06d9e
commit b6e21d422e
2 changed files with 31 additions and 0 deletions
+22
View File
@@ -2257,4 +2257,26 @@ function test_addBack() {
// Second Example
$("div.after-addback").find("p").addBack().addClass("background");
}
// http://api.jquery.com/jQuery.parseHTML/
function test_parseHTML() {
var $log = $( "#log" ),
str = "hello, <b>my name is</b> jQuery.",
html = $.parseHTML( str ),
nodeNames = [];
// Append the parsed HTML
$log.append( html );
// Gather the parsed HTML's node names
$.each( html, function( i, el ) {
nodeNames[i] = "<li>" + el.nodeName + "</li>";
});
// Insert the node names
$log.append( "<h3>Node Names:</h3>" );
$( "<ol></ol>" )
.append( nodeNames.join( "" ) )
.appendTo( $log );
}