From 15e56b924dc8b5b4f1ebece97a62250b81b270ed Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Wed, 1 Jan 2014 06:45:20 +0000 Subject: [PATCH] jQuery: added html JSDoc --- jquery/jquery-tests.ts | 2 +- jquery/jquery.d.ts | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 35210e4bb..7cbcc3bd0 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1710,7 +1710,7 @@ function test_html() { }); $('div.demo-container') .html('

All new content. You bet!

'); - $('div.demo-container').html(function () { + $('div.demo-container').html(function (index, oldhtml) { var emph = '' + $('p').length + ' paragraphs!'; return '

All new content for ' + emph + '

'; }); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 2f64de24e..5b9983339 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -783,10 +783,27 @@ interface JQuery { */ hasClass(className: string): boolean; + /** + * Get the HTML contents of the first element in the set of matched elements. + */ html(): string; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param htmlString A string of HTML to set as the content of each matched element. + */ html(htmlString: string): JQuery; - html(htmlContent: (index: number, oldhtml: string) => string): JQuery; - html(obj: JQuery): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @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. + */ + html(func: (index: number, oldhtml: string) => string): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @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. + */ /** * Get the value of a property for the first element in the set of matched elements.