dqcqcqwq38860 2015-04-25 12:04
浏览 58

执行Ajax函数后,按钮单击不起作用[重复]

This question is an exact duplicate of:

I have a readmore button which is generated with Ajax and now I am using below code to execute a click event from this button, but nothing happens.

The button when clicked should unhide a div which is also dynamic and generated with Ajax. So this is all dynamic content I am dealing any ideas please. Thanks.

jQuery:

jQuery(document).on('click', '#readmore', function(e){
    e.preventDefault();
    alert("you clicked the button");
    jQuery("#bodytext").css("display", "block");
});
</div>
  • 写回答

1条回答 默认 最新

  • dongyao1915 2015-04-25 12:19
    关注

    You have 2 options to make it work,

    1. convert your button to hyperlink as e.preventDefault will prevent to click of button as it is its default behavior.
    2. Remove the e.preventDefault() from your code.

    Also make sure your have included any latest version of jquery. And write your code in $.ready() like,

    $(function(){
        // your code here
    });
    

    Now, try to use any one option from the above.

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大