2

jquery イベントで 1 つのリスト項目から矢印アイコンを削除しようとしています。

1 つのリスト項目:

<li class='message_list'><a id='message_list_item' href='#'>
<h3>Sender</h3>
<p><strong>Subject</strong></p>
<p>Body Text</p>
<p class='ui-li-aside'><strong>Time</strong>am</p>
</a></li>

脚本:

$(".message_list").swipeleft(function(event) {
    event.stopImmediatePropagation(); //prevent from firing twice
    $(this).attr('data-icon', 'false');
    $("#test_display").html("Worked");      

    return false;
});

テスト html が更新されるため、スクリプトがアクティブになります。しかし、なぜその属性の変更が機能しないのでしょうか?

しかし、置く<li data-icon='false' class='message_list'>ことはそれを取り除きます!

4

1 に答える 1

0

data-*属性はデータを通じてサポートされます。使ってみて -

 $(this).data('icon', 'false');

その後、後で使用して確認できます-

$(this).data('icon');    // will return false if set to false.
于 2012-12-06T03:32:03.573 に答える