Created
June 29, 2012 02:06
-
-
Save ledsun/3015221 to your computer and use it in GitHub Desktop.
jQueryオブジェクトの属性操作
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
/*globals define */ | |
/* | |
* jQuery checkAttr 0.0.1 | |
* | |
* 属性操作用のメソッドを追加します。 | |
* Licensed under the MIT (MIT-LICENSE.txt) | |
* | |
*/ | |
define([ | |
], function () { | |
$.fn.checkAttr = function (attrName, bool) { | |
if (bool === undefined) { //第二引数が指定されなかったら | |
return $(this).attr(attrName) === attrName; | |
} | |
return this.each(function () { | |
if (bool) { | |
$(this).attr(attrName, attrName); | |
} else { | |
$(this).removeAttr(attrName); | |
} | |
}); | |
}; | |
}); |
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
/*globals define */ | |
/* | |
* jQuery checked 0.0.1 | |
* | |
* checked属性操作用のメソッドを追加します。 | |
* Licensed under the MIT (MIT-LICENSE.txt) | |
* | |
*/ | |
define([ | |
'common/jquery.checkAttr' | |
], function () { | |
$.fn.checked = function (bool) { | |
return $(this).checkAttr('checked', bool); | |
}; | |
}); |
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
/*globals define */ | |
/* | |
* jQuery disabled 0.0.1 | |
* | |
* disabled 属性操作用のメソッドを追加します。 | |
* Licensed under the MIT (MIT-LICENSE.txt) | |
* | |
*/ | |
define([ | |
'common/jquery.checkAttr' | |
], function () { | |
$.fn.disabled = function (bool) { | |
return $(this).checkAttr('disabled', bool); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment