【问题标题】:click event not working with form plugin点击事件不适用于表单插件
【发布时间】:2014-03-27 19:10:56
【问题描述】:

我正在使用 jquery 表单插件上传图片而无需重新加载页面,但似乎无法添加点击功能。我不知道我做错了什么?

代码:

$(document).ready(function () {
var options = {  
    url:'img_handler.php',
    type:'POST', 
    success:function(data) {
        //all the events are handeled properly
    } 
};  
$(".post_the_img-sing").click(function () {///the probem is over here 
$('#post_image_to_stream-single').ajaxForm(options);
});
});

注意:我不可能在表单中使用.post_the_img_sing 按钮


更新:发现我可以使用隐藏的提交按钮,然后只需将点击事件添加到 div .post_the_img_sing

【问题讨论】:

  • 那是动态元素吗?
  • 要添加到@AnoopJoshi 询问的内容,如果这是动态内容,您需要使用$(document).on("click", ".post_the_img-sing", function() { //code });
  • 不,它不会以任何方式改变

标签: jquery ajax image forms submit


【解决方案1】:

对我来说看起来不错,就这段代码而言......你检查过类名吗?因为在你的代码中你有.post_the_img-sing,但是你写了.post_the_img_sing...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-29
    • 2019-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 1970-01-01
    • 2011-10-12
    相关资源
    最近更新 更多