mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Fix jQuery each definition
This commit is contained in:
Vendored
+1
-1
@@ -614,7 +614,7 @@ interface JQuery {
|
||||
/*************
|
||||
MISCELLANEOUS
|
||||
**************/
|
||||
each(func: (index: any, elem: Element) => JQuery);
|
||||
each(func: (index: any, elem: Element) => any);
|
||||
|
||||
get(index?: number): any;
|
||||
|
||||
|
||||
@@ -465,4 +465,34 @@ function test_attributeSelectors() {
|
||||
$('input[value="Hot Fuzz"]').next().text(" Hot Fuzz");
|
||||
$('input[name!="newsletter"]').next().append('<b>; not newsletter</b>');
|
||||
$('input[name^="news"]').val('news here!');
|
||||
}
|
||||
|
||||
function test_each() {
|
||||
$('li').each(function (index) {
|
||||
alert(index + ': ' + $(this).text());
|
||||
});
|
||||
$(document.body).click(function () {
|
||||
$("div").each(function (i) {
|
||||
if (this.style.color != "blue") {
|
||||
this.style.color = "blue";
|
||||
} else {
|
||||
this.style.color = "";
|
||||
}
|
||||
});
|
||||
});
|
||||
$("span").click(function () {
|
||||
$("li").each(function () {
|
||||
$(this).toggleClass("example");
|
||||
});
|
||||
});
|
||||
$("button").click(function () {
|
||||
$("div").each(function (index, domEle) {
|
||||
// domEle == this
|
||||
$(domEle).css("backgroundColor", "yellow");
|
||||
if ($(this).is("#stop")) {
|
||||
$("span").text("Stopped at div index #" + index);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user