jQuery: are we there yet?

This commit is contained in:
John Reilly
2014-03-17 14:39:08 +00:00
parent f48f188c6c
commit b18a971c9a
2 changed files with 132 additions and 4 deletions
+31
View File
@@ -2272,6 +2272,37 @@ function test_scrollTop() {
$("div.demo").scrollTop(300);
}
function test_parent() {
$("*", document.body).each(function () {
var parentTag = $(this).parent().get(0).tagName;
$(this).prepend(document.createTextNode(parentTag + " > "));
});
$("p").parent(".selected").css("background", "yellow");
}
function test_parents() {
var parentEls = $("b").parents()
.map(function () {
return this.tagName;
})
.get()
.join(", ");
$("b").append("<strong>" + parentEls + "</strong>");
function showParents() {
$("div").css("border-color", "white");
var len = $("span.selected")
.parents("div")
.css("border", "2px red solid")
.length;
$("b").text("Unique div parents: " + len);
}
$("span").click(function () {
$(this).toggleClass("selected");
showParents();
});
}
function test_param() {
function test1() {