Fix jQuery prop() definition and add some tests

This commit is contained in:
Boris Yankov committed 2012-11-09 19:58:37 +02:00
1 parent e7ac778279
commit 02b302faa7
2 files changed
+19 -3

No files matched your search

+18 -2
View File
@@ -689,7 +689,7 @@ function test_children() {
var len = $kids.addClass("hilite").length;
$("#results span:first").text(len.toString());
$("#results span:last").text(e.target.tagName);
//$("#results span:last").text(e.target.tagName);
e.preventDefault();
return false;
@@ -765,7 +765,7 @@ function test_closest() {
});
var $listElements = $("li").css("color", "blue");
$(document).bind("click", function (e) {
$(e.target).closest($listElements).toggleClass("hilight");
//$(e.target).closest($listElements).toggleClass("hilight");
});
}
@@ -902,6 +902,22 @@ function test_each() {
});
}
function test_prop() {
var $input = $(this);
$("p").html(".attr('checked'): <b>" + $input.attr('checked') + "</b><br>"
+ ".prop('checked'): <b>" + $input.prop('checked') + "</b><br>"
+ ".is(':checked'): <b>" + $input.is(':checked')) + "</b>";
$("input").prop("disabled", false);
$("input").prop("checked", true);
$("input").val("someValue");
$("input[type='checkbox']").prop("checked", function (i, val) {
return !val;
});
$("input[type='checkbox']").prop({
disabled: true
});
}
function test_text() {
var str = $("p:first").text();
$("p:last").html(str);