Skip to content

Commit f22511d

Browse files
committed
Merge pull request DefinitelyTyped#1490 from johnnyreilly/master
jQuery: added html JSDoc
2 parents 2506787 + 15e56b9 commit f22511d

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

jquery/jquery-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ function test_html() {
17101710
});
17111711
$('div.demo-container')
17121712
.html('<p>All new content. <em>You bet!</em></p>');
1713-
$('div.demo-container').html(function () {
1713+
$('div.demo-container').html(function (index, oldhtml) {
17141714
var emph = '<em>' + $('p').length + ' paragraphs!</em>';
17151715
return '<p>All new content for ' + emph + '</p>';
17161716
});

jquery/jquery.d.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,27 @@ interface JQuery {
783783
*/
784784
hasClass(className: string): boolean;
785785

786+
/**
787+
* Get the HTML contents of the first element in the set of matched elements.
788+
*/
786789
html(): string;
790+
/**
791+
* Set the HTML contents of each element in the set of matched elements.
792+
*
793+
* @param htmlString A string of HTML to set as the content of each matched element.
794+
*/
787795
html(htmlString: string): JQuery;
788-
html(htmlContent: (index: number, oldhtml: string) => string): JQuery;
789-
html(obj: JQuery): JQuery;
796+
/**
797+
* Set the HTML contents of each element in the set of matched elements.
798+
*
799+
* @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set.
800+
*/
801+
html(func: (index: number, oldhtml: string) => string): JQuery;
802+
/**
803+
* Set the HTML contents of each element in the set of matched elements.
804+
*
805+
* @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set.
806+
*/
790807

791808
/**
792809
* Get the value of a property for the first element in the set of matched elements.

0 commit comments

Comments
 (0)