誤り
if ($(hoge).hasClass('.foobar')) {
}
if ($(hoge).is('foobar')) {
}
正しい
if ($(hoge).hasClass('foobar')) {
}
if ($(hoge).is('.foobar')) {
}
冷静に考えれば当たり前の話ですが、普段セレクタ書いてること多いと $(hoge).hasClass('.foobar')
は特にやりがち。
More than 5 years have passed since last update.
if ($(hoge).hasClass('.foobar')) {
}
if ($(hoge).is('foobar')) {
}
if ($(hoge).hasClass('foobar')) {
}
if ($(hoge).is('.foobar')) {
}
冷静に考えれば当たり前の話ですが、普段セレクタ書いてること多いと $(hoge).hasClass('.foobar')
は特にやりがち。
Register as a new user and use Qiita more conveniently