jQuery: expanded text to cover number and boolean

following input from @dmethvin
This commit is contained in:
John Reilly
2014-03-13 14:02:36 +00:00
parent f1cd2ccc32
commit 64f7f2b630
2 changed files with 28 additions and 16 deletions
+14 -14
View File
@@ -418,7 +418,7 @@ function test_slideToggle() {
$("#aa").click(function () {
$("div:not(.still)").slideToggle("slow", function () {
var n = parseInt($("span").text(), 10);
$("span").text((n + 1).toString());
$("span").text(n + 1);
});
});
}
@@ -763,7 +763,7 @@ function test_children() {
var $kids = $(e.target).children();
var len = $kids.addClass("hilite").length;
$("#results span:first").text(len.toString());
$("#results span:first").text(len);
//$("#results span:last").text(e.target.tagName);
e.preventDefault();
@@ -2143,13 +2143,13 @@ function test_html() {
function test_inArray() {
var arr: any[] = [4, "Pete", 8, "John"];
var $spans = $("span");
$spans.eq(0).text(jQuery.inArray("John", arr).toString());
$spans.eq(1).text(jQuery.inArray(4, arr).toString());
$spans.eq(2).text(jQuery.inArray("Karl", arr).toString());
$spans.eq(3).text(jQuery.inArray("Pete", arr, 2).toString());
$spans.eq(0).text(jQuery.inArray("John", arr));
$spans.eq(1).text(jQuery.inArray(4, arr));
$spans.eq(2).text(jQuery.inArray("Karl", arr));
$spans.eq(3).text(jQuery.inArray("Pete", arr, 2));
var arr2: number[] = [1, 2, 3, 4];
$spans.eq(1).text(jQuery.inArray(4, arr2).toString());
$spans.eq(1).text(jQuery.inArray(4, arr2));
}
function test_index() {
@@ -2384,7 +2384,7 @@ function test_isFunction() {
];
jQuery.each(objs, function (i) {
var isFunc = jQuery.isFunction(objs[i]);
$("span").eq(i).text(isFunc.toString());
$("span").eq(i).text(isFunc);
});
$.isFunction(function () { });
}
@@ -2749,7 +2749,7 @@ function test_mouseenter() {
var n = 0;
$("div.enterleave").mouseenter(function () {
$("p:first", this).text("mouse enter");
$("p:last", this).text((++n).toString());
$("p:last", this).text(++n);
}).mouseleave(function () {
$("p:first", this).text("mouse leave");
});
@@ -2767,14 +2767,14 @@ function test_mouseleave() {
$("p:first", this).text("mouse over");
}).mouseout(function () {
$("p:first", this).text("mouse out");
$("p:last", this).text((++i).toString());
$("p:last", this).text(++i);
});
var n = 0;
$("div.enterleave").mouseenter(function () {
$("p:first", this).text("mouse enter");
}).mouseleave(function () {
$("p:first", this).text("mouse leave");
$("p:last", this).text((++n).toString());
$("p:last", this).text(++n);
});
}
@@ -2805,7 +2805,7 @@ function test_mouseout() {
var i = 0;
$("div.overout").mouseout(function () {
$("p:first", this).text("mouse out");
$("p:last", this).text((++i).toString());
$("p:last", this).text(++i);
}).mouseover(function () {
$("p:first", this).text("mouse over");
});
@@ -2814,7 +2814,7 @@ function test_mouseout() {
$("p:first", this).text("mouse enter");
}).bind("mouseleave", function () {
$("p:first", this).text("mouse leave");
$("p:last", this).text((++n).toString());
$("p:last", this).text(++n);
});
}
@@ -2847,7 +2847,7 @@ function test_mouseover() {
var i = 0;
$("div.overout").mouseover(function () {
$("p:first", this).text("mouse over");
$("p:last", this).text((++i).toString());
$("p:last", this).text(++i);
}).mouseout(function () {
$("p:first", this).text("mouse out");
});
+14 -2
View File
@@ -3086,9 +3086,21 @@ interface JQuery {
/**
* Set the content of each element in the set of matched elements to the specified text.
*
* @param textString A string of text to set as the content of each matched element.
* @param text The text to set as the content of each matched element.
*/
text(textString: string): JQuery;
text(text: string): JQuery;
/**
* Set the content of each element in the set of matched elements to the specified text.
*
* @param text The text to set as the content of each matched element.
*/
text(text: number): JQuery;
/**
* Set the content of each element in the set of matched elements to the specified text.
*
* @param text The text to set as the content of each matched element.
*/
text(text: boolean): JQuery;
/**
* Set the content of each element in the set of matched elements to the specified text.
*