Skip to content

Commit

Permalink
JQuery equivalent removeAttr method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Russell committed Jan 11, 2011
1 parent fe781ad commit d576f13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/zepto.js
Expand Up @@ -121,6 +121,9 @@ var Zepto = (function() {
else this.setAttribute(name, value); else this.setAttribute(name, value);
}); });
}, },
removeAttr: function(name) {
return this.each(function() { this.removeAttribute(name); });
},
val: function(value){ val: function(value){
return (value === undefined) ? return (value === undefined) ?
(this.length > 0 ? this.dom[0].value : null) : (this.length > 0 ? this.dom[0].value : null) :
Expand Down
12 changes: 12 additions & 0 deletions test/zepto.html
Expand Up @@ -676,7 +676,19 @@ <h1>Zepto DOM unit tests</h1>
els.attr('value', ''); els.attr('value', '');
t.assertEqual(els.get(0).value, els.attr('value')); t.assertEqual(els.get(0).value, els.attr('value'));
t.assertEqual('', els.attr('value')); t.assertEqual('', els.attr('value'));
},

testRemoveAttr: function(t) {
var els = $('#attr_with_text_input');

els.get(0).removeAttribute('disabled');
t.assertEqual(els.attr('disabled'), undefined);


els.attr('disabled', 'definitely');
t.assertEqual(els.attr('disabled'), 'definitely');

els.removeAttr('disabled');
t.assertEqual(els.attr('disabled'), undefined);
}, },


testVal: function(t) { testVal: function(t) {
Expand Down

0 comments on commit d576f13

Please sign in to comment.