2012-12-06 101 views
2

我想从一个列表项目中删除箭头图标与jquery事件。jquery mobile,列表,隐藏箭头图标

一个列表项:

<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'>确实删除它!

回答

0

data-*属性通过data支持。尝试使用 -

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

,再后来,你可以检查使用 -

$(this).data('icon'); // will return false if set to false. 
+0

使用这些数据不会从箭头-R更改为false(或任何其他图标我将它设置为),但图标依旧显示器。 – Fred

+0

@Fred:可能您需要明确地将图标可见性设置为false,或者存在其他一些机制来隐藏它。 –