使い方
$("foo").hasClasses(classes);
fooには、複数のclassが設定されているか調べたい要素のセレクタを指定します。
引数
classes
classesには、次のいずれかの書き方で調べたいclassを設定します。
// 半角スペース区切りの文字列
$("foo").hasClasses("foo bar");
// CSSのセレクタのようなドットでつなぐ文字列
$("foo").hasClasses(".foo.bar");
// 配列
$("foo").hasClasses(["foo","bar"]);
サンプル
user.jsに以下の様に記述すると、フォーカスしたtextareaにfullとlowというclassが指定してある場合、textareaの高さが200pxに伸びます。
$("textarea").focus(function(){
if ($(this).hasClasses("full low")) {
$(this).height(200);
}
});