jQuery = function(a,c) {
// Shortcut for document ready (because $(document).each() is silly)
- if ( a && a.constructor == Function && jQuery.fn.ready )
+ if ( a && typeof a == "function" && jQuery.fn.ready )
return jQuery(document).ready(a);
// Make sure that a selection was provided
var fn = arguments[ arguments.length - 1 ];
// If so, execute it in context
- if ( fn && fn.constructor == Function )
+ if ( fn && typeof fn == "function" )
this.each(fn);
};
t.constructor == Boolean &&
( t ? this.get() : [] ) ||
- t.constructor == Function &&
+ typeof t == "function" &&
jQuery.grep( this, t ) ||
jQuery.filter(t,this).r, arguments );
} else {
var old = this.get();
this.get( a );
- if ( fn.constructor == Function )
+ if ( typeof fn == "function" )
this.each( fn );
this.get( old );
}
o.className += ( o.className ? " " : "" ) + c;
},
remove: function(o,c){
+ /*
o.className = !c ? "" :
o.className.replace(
- new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
+ new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");*/
+ if( !c ) {
+ o.className = "";
+ } else {
+ var classes = o.className.split(" ");
+ for(var i=0; i<classes.length; i++) {
+ if(classes[i] == c) {
+ classes.splice(i, 1);
+ break;
+ }
+ }
+ o.className = classes.join(' ');
+ }
},
has: function(e,a) {
if ( e.className != undefined )
* @test t( "Form element :radio", ":radio", ["radio1", "radio2"] );
* @test t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
* @test t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
+ * @test t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
+ * @test t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
+ * @test t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
*
* @test t( ":not() Existing attribute", "input:not([@name])", ["text2", "check2"]);
* @test t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
* }
* ok( pass, "Remove Class" );
*
+ * @test var div = $("div").addClass("test").addClass("foo").addClass("bar");
+ * div.removeClass("test").removeClass("bar").removeClass("foo");
+ * var pass = true;
+ * for ( var i = 0; i < div.size(); i++ ) {
+ * if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
+ * }
+ * ok( pass, "Remove multiple classes" );
+ *
* @name removeClass
* @type jQuery
* @param String class A CSS class to remove from the elements