Fixed .val(String) for select elements (#1760) [Thanks Sam]

This commit is contained in:
Brandon Aaron 2007-10-12 12:51:07 +00:00
parent 0f5c1d15e9
commit 971840f343
2 changed files with 5 additions and 2 deletions

View file

@ -407,7 +407,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.inArray( this.text, values ) >= 0);
});
if ( !tmp.length )
if ( !values.length )
this.selectedIndex = -1;
} else

View file

@ -824,11 +824,14 @@ test("val()", function() {
});
test("val(String)", function() {
expect(2);
expect(3);
document.getElementById('text1').value = "bla";
ok( $("#text1").val() == "bla", "Check for modified value of input element" );
$("#text1").val('test');
ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
$("#select1").val("3");
ok( $("#select1").val() == "3", "Check for modified (via val(String)) value of select element" );
});
test("html(String)", function() {