(function(){
if ($('#right-col').hasClass('shown')){
$(this).swipe({
swipe:function(event, direction, distance, duration, fingerCount) {
$(this).addClass('hidden');//.text(direction);
}
});
};
})();
これは、私が取り組んでいる Web プロジェクトのスワイプ機能です。しかし、どういうわけか、私のコードは if ステートメントでは機能しません。これだけを使用する場合:
$('#right-col').swipe({
swipe:function(event, direction, distance, duration, fingerCount) {
$(this).addClass('bg-blue').text("You swiped " + direction );
}
})
それは正常に動作します。上記の自己呼び出し関数で特に何が問題なのか、誰か教えてもらえますか?