Fixed some bugs with attribute handling.

This commit is contained in:
John Resig 2006-08-09 05:44:25 +00:00
parent f2d4bffcc7
commit 6a50758086

10
jquery/jquery.js vendored
View file

@ -241,7 +241,7 @@ jQuery.fn = jQuery.prototype = {
*/ */
attr: function( key, value, type ) { attr: function( key, value, type ) {
// Check to see if we're setting style values // Check to see if we're setting style values
return key.constructor != String || value ? return key.constructor != String || value != undefined ?
this.each(function(){ this.each(function(){
// See if we're setting a hash of styles // See if we're setting a hash of styles
if ( value == undefined ) if ( value == undefined )
@ -760,6 +760,12 @@ jQuery.extend({
}; };
}); });
jQuery.each( jQuery.macros.filter, function(i,n){
jQuery.fn[ n ] = function(num,fn) {
return this.filter( ":" + n + "(" + num + ")", fn );
};
});
jQuery.each( jQuery.macros.attr, function(i,n){ jQuery.each( jQuery.macros.attr, function(i,n){
n = n || i; n = n || i;
jQuery.fn[ i ] = function(h) { jQuery.fn[ i ] = function(h) {
@ -1739,6 +1745,8 @@ jQuery.macros = {
css: "width,height,top,left,position,float,overflow,color,background".split(","), css: "width,height,top,left,position,float,overflow,color,background".split(","),
filter: [ "eq", "lt", "gt", "contains" ],
attr: { attr: {
/** /**
* Get the current value of the first matched element. * Get the current value of the first matched element.