【问题标题】:JQuery selector based on ID in Coffee ScriptCoffee Script中基于ID的jQuery选择器
【发布时间】:2017-09-14 10:27:53
【问题描述】:

我有以下回调(咖啡脚本):

$(document).on 'ajax:success', 'a.add_to_cart', (status, data, xhr)->

a.add_to_cartlink_toclass=add_to_cart 的选择器。

button_to 的选择器是什么(基于它的 id)?

【问题讨论】:

  • 这似乎不起作用。
  • 那么我建议使用minimal reproducible example 更新问题,因为如果不是 ID 选择器,则不清楚您要查找的内容。

标签: jquery ruby-on-rails coffeescript


【解决方案1】:

ID 应该只分配给页面上的一个元素。如果你给它一个foo的id,那么你可以使用#foo jquery选择器来引用,因为#意味着id。

无论如何,button_to 会生成<button>,您始终可以使用浏览器开发工具检查器查看生成的 HTML。

【讨论】:

    猜你喜欢
    • 2012-09-18
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    • 2012-04-27
    • 2010-10-11
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    相关资源
    最近更新 更多