【问题标题】:jquery button not working with classjquery按钮不适用于类
【发布时间】:2014-09-11 05:38:29
【问题描述】:

HTML 代码:

<input type="button" id="close" class"close_tag">

jQuery 代码:

close id 工作正常,并且 close id 关联了很多函数

 $(document).on('click','#close',function(){
   works very fine...
    action is performed successfully .
});

但是这个不行

  $(document).on('click','.close_tag',function(){

    don:t perform any specific actions.
});

【问题讨论】:

  • 你在课后错过了=。应该是class="close_tag"
  • 您的&lt;input&gt; 标签中似乎缺少=。应该是class="close_tag"
  • 谢谢你的工作......

标签: javascript jquery button


【解决方案1】:

它不起作用,因为您的 HTML 中有错字

<input type="button" id="close" class"close_tag">
                                     ^

应该是

<input type="button" id="close" class="close_tag">
                                     ^

【讨论】:

  • 在我的代码中是
  • 比您提供的代码中未显示的问题。由于所有答案都基于您代码中的错字。您不妨将其删除,使用更多显示问题的代码重新开始,并使用真实代码,以免出现拼写错误。
【解决方案2】:

改变这个

&lt;input type="button" id="close" class"close_tag"&gt;

收件人

<input type="button" id="close" class="close_tag">

class="close_tag" 不是类"close_tag"

DEMO

【讨论】:

  • 在我的代码中它是相同的 但不会工作
  • class"close_tag"改成class="close_tag"。你忘了=分配班级
  • 添加完整的 html 和 js,也许问题出在其他地方:)
【解决方案3】:

也许尝试修复您的按钮(只需添加相等)

<input type="button" id="close" class="close_tag">

【讨论】:

    猜你喜欢
    • 2018-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多