]> source.dussan.org Git - jquery.git/commitdiff
Fixed .val(String) for select elements (#1760) [Thanks Sam]
authorBrandon Aaron <brandon.aaron@gmail.com>
Fri, 12 Oct 2007 12:51:07 +0000 (12:51 +0000)
committerBrandon Aaron <brandon.aaron@gmail.com>
Fri, 12 Oct 2007 12:51:07 +0000 (12:51 +0000)
src/core.js
test/unit/core.js

index 9fd0168e62732522ace73ac5d0e276ad68cab031..b3b0a9d27ad64d0fe85992d05366607b081d3fcf 100644 (file)
@@ -407,7 +407,7 @@ jQuery.fn = jQuery.prototype = {
                                                        jQuery.inArray( this.text, values ) >= 0);\r
                                        });\r
 \r
-                                       if ( !tmp.length )\r
+                                       if ( !values.length )\r
                                                this.selectedIndex = -1;\r
 \r
                                } else\r
index 32ff83e8613a32c2dfba93fedff7d3481aa2dfd0..eee1740d6361d99c959eccbe1d3db98169772cb1 100644 (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() {