mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
jquery: parseHTML(...) added. #421
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
9
jquery/jquery.d.ts
vendored
9
jquery/jquery.d.ts
vendored
@@ -353,6 +353,15 @@ interface JQueryStatic {
|
||||
type(obj: any): string;
|
||||
|
||||
unique(arr: any[]): any[];
|
||||
|
||||
/**
|
||||
* Parses a string into an array of DOM nodes.
|
||||
*
|
||||
* @param data HTML string to be parsed
|
||||
* @param context DOM element to serve as the context in which the HTML fragment will be created
|
||||
* @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
|
||||
*/
|
||||
parseHTML(data: string, context?: HTMLElement, keepScripts?: bool): any[];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user