hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
// If set returns undefined, fall back to normal setting
- if ( !hooks || ("set" in hooks && hooks.set( this, val, "value" ) === undefined) ) {
+ if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
});
});
test("val()", function() {
- expect(25);
+ expect(26);
document.getElementById("text1").value = "bla";
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
+
+ equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
});
var testVal = function(valueObj) {