http://jquery.com/upgrade-guide/1.9/#hover-pseudo-eventに基づいて、mouseenter、mouseleave イベントを実際に使用する必要があります。フィドルには、クリック時に親要素のデータを設定する部分があります。もっと簡単かもしれません:
$('li.list-item').on('mouseenter', '>a:not(.active)', function () {
$(this).clearQueue().stop().animate({
marginLeft: 40
}, 250);
});
$('li.list-item').on('mouseleave', '>a:not(.active)', function () {
$(this).clearQueue().stop().animate({
marginLeft: 0
}, 250);
});
$('.list-item[data-toggle="collapse"] ').on('click', '>a', function () {
$(this).parent().data('attr', !$(this).parent().data('attr'));
});
EDIT1:サイドノート、次の.parent()
ようにトラバーサルを保存するリンクではなく、要素でその2番目のイベントをキャプチャすることもできます:
$('.list-item[data-toggle="collapse"] ').click( function () {
$(this).data('attr', !$(this).data('attr'));
});
そして、これらの li 要素を動的に作成している場合は、ul に添付します。
$('ul').on('click', '.list-item[data-toggle="collapse"] ', function () {
alert($(this).data('attr'));
$(this).data('attr', !$(this).data('attr'));
});