Created
April 30, 2010 16:28
-
-
Save westonruter/385435 to your computer and use it in GitHub Desktop.
jQuery.fn.prop(name, vaue): Same as jQuery('…').attr(name, value) but for DOM attributes (properties)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Same as jQuery('…').attr(name, value) but for DOM attributes (properties) | |
* @param {string} name The property name | |
* @param {mixed} value The property value | |
* @todo Allow for passing setter | |
*/ | |
jQuery.fn.prop = function(name, value){ | |
if(typeof value == 'undefined'){ | |
return this.length ? this[0][name] : null; | |
} | |
this.each(function(){ | |
this[name] = value; | |
}); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment