无法使用 jQuery 选择器访问单击事件

Not able to access click event with jQuery selector

本文关键字:访问 单击 事件 选择器 jQuery      更新时间:2023-09-26

即使使用jQuery选择器,我也很难访问单击。这是我的 HTML:

<li class="handle-bars">
    <span class="fa fa-bars pull-right text-primary m-t-10"></span>
    <span class="fa fa-cogs pull-right text-primary m-t-10" id="trigger-modal-editor" style="cursor:pointer" data-target="#modalSlideLeft" data-toggle="modal">     </span>
</li>

这是我的jQuery选择器:

<script>
$(document).ready(function() {
  $('#trigger-modal-editor').click(function() {
    alert('Hello');
  });
</script>

由于某种原因,这不是注册艺术品。任何帮助不胜感激!

你忘了关闭就绪处理程序:

$(document).ready(function() {
  $('#trigger-modal-editor').click(function() {
    alert('Hello');
  });
});//this 

另外,您#trigger-modal-editor内没有任何文本,请在此处放置一些文本以单击。