【问题标题】:Remove image in jQuery Mobile li在 jQuery Mobile li 中删除图像
【发布时间】:2013-03-12 08:53:51
【问题描述】:

我希望每次用户单击一行时在 jQuery 列表视图中切换一个图标。

Here is the complete source code.

以下代码似乎不起作用:

$(this).remove('img');

我也试过了:

$(this).remove('icon');

有什么想法吗?

【问题讨论】:

    标签: jquery image listview jquery-mobile


    【解决方案1】:

    尝试以下方法:

    $(this).find('img').remove();
    

    Here's the updated Fiddle.

    【讨论】:

    • 好的,谢谢。但是根据jQuery API,我的版本应该可以工作。你明白为什么不这样做吗?
    • 这当然是一种奇怪的行为,看起来remove() 运行正常,但正如this bug report 显示的那样令人困惑。
    • @Maxbester,您误解了文档。来自具有.hello 的文档$('div').remove('.hello'); means remove the div`。参数充当filter(不是selector)。您的代码 $(this).remove('img'); 表示从 $(this) 的数组中过滤具有 img 标记的元素并仅将其删除。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 2011-10-27
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多