+var rclass = /[\n\t]/g;
+
jQuery.fn.extend({
attr: function( name, value ) {
return access(this, name, value, true, jQuery.attr);
if ( elem.nodeType === 1 && elem.className ) {
if ( value ) {
- var className = " " + elem.className + " ";
+ var className = (" " + elem.className + " ").replace(rclass, " ");
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
className = className.replace(" " + classNames[c] + " ", " ");
}
hasClass: function( selector ) {
var className = " " + selector + " ";
for ( var i = 0, l = this.length; i < l; i++ ) {
- if ( (" " + this[i].className + " ").indexOf( className ) > -1 ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
return true;
}
}
jQuery.each({
removeAttr: function( name ) {
+ jQuery.attr( this, name, "" );
if ( this.nodeType === 1 ) {
- this[ jQuery.isXMLDoc( this ) ? name : jQuery.props[ name ] || name ] = null;
this.removeAttribute( name );
}
},
jQuery.extend({
attrFn: {
val: true,
- addClass: true,
css: true,
html: true,
text: true,
- append: true,
- prepend: true,
data: true,
width: true,
height: true,
- offset: true,
- bind: true
+ offset: true
},
attr: function( elem, name, value ) {
return undefined;
}
- if ( name in jQuery.attrFn ) {
+ if ( name in jQuery.attrFn && value !== undefined ) {
return jQuery(elem)[name](value);
}