if ( name in elem && notxml && !special ) {
if ( set ){
// We can't allow the type property to be changed (since it causes problems in IE)
- if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
+ if ( name == "type" && elem.nodeName.match(/(button|input)/i) && elem.parentNode )
throw "type property can't be changed";
elem[ name ] = value;
<input type="text" id="name" name="name" value="name" />
<input type="search" id="search" name="search" value="search" />
- <button id="button" name="button">Button</button>
+ <button id="button" name="button" type="button">Button</button>
<textarea id="area1" maxlength="30">foobar</textarea>
});
test("attr(String, Object)", function() {
- expect(19);
+ expect(21);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
for ( var i = 0; i < div.size(); i++ ) {
}
ok( thrown, "Exception thrown when trying to change type property" );
equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
+
+ var button = jQuery("#button");
+ var thrown = false;
+ try {
+ button.attr('type','submit');
+ } catch(e) {
+ thrown = true;
+ }
+ ok( thrown, "Exception thrown when trying to change type property" );
+ equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" );
});
if ( !isLocal ) {