Javascript jQuery-隐藏显示在Chrome中无法正常工作(仅工作一次)

Javascript jQuery-隐藏显示在Chrome中无法正常工作(仅工作一次),javascript,jquery,google-chrome,show-hide,Javascript,Jquery,Google Chrome,Show Hide,刚刚编写了一个jquery,当单击文本区域时,它会显示一个注释按钮。隐藏注释按钮,单击屏幕中的其他位置。它在Firefox中运行良好。但在Chrome中,它只能工作一次。当我再次点击textarea时,submit按钮没有显示,它仍然是隐藏的 $(document).on('click', ".comment_txt, .comment_btn", function() { var post_id = $(this).attr("post-id"); $("#comment_

刚刚编写了一个jquery,当单击文本区域时,它会显示一个注释按钮。隐藏注释按钮,单击屏幕中的其他位置。它在Firefox中运行良好。但在Chrome中,它只能工作一次。当我再次点击textarea时,submit按钮没有显示,它仍然是隐藏的

$(document).on('click', ".comment_txt, .comment_btn", function() {
  var post_id = $(this).attr("post-id");      
  $("#comment_btn_div_"+post_id).show();
});
$('body').click(function() {
  $(".comment_btn").hide()
});


<form class="comment_submit" action="http://localhost:3000/api/v2/posts/48774/comment" data-post-id="48774" id="comment_form_48774">
    <textarea post-id="48774" id="comment_txt_48774" placeholder="Comment" cols="40" rows="1" class="width100 comment_txt"></textarea>
    <div id="comment_btn_div_48774" class="right comment_btn" post-id="48774" style="display:none">
      <button onclick="$(this).text('commenting...')" class="btn btn-small btn-info right" id="comment_btn_48774" type="submit">Comment</button>
    </div>
</form>
单击文本区域,得到警报a。身体b。单击文本区域。现在显示注释按钮 我的身体得到了警报a。身体发出咔哒声。现在注释按钮被隐藏 单击文本区域,得到警报a。身体b。单击文本区域。现在不显示“注释”按钮。 谢谢

试试模糊

$(document).on('click', ".comment_txt, .comment_btn", function () {
    var post_id = $(this).attr("post-id");
    $("#comment_btn_div_" + post_id).show();
});

$('.comment_txt').blur(function () {
    $(".comment_btn").hide()
});

我偶尔会碰到这个。还没有弄清楚为什么会这样;这使我困惑。我用另一种显示div的方法来解决这个问题。最近,我更改了css显示属性:

$comment_btn_div_+post_id.css'display','block'

var post_id=null;
$(document).on('click', ".comment_txt, .comment_btn", function(event) {
  post_id = $(this).attr("post-id");      
   $("#comment_btn_div_"+post_id).show();
   event.stopPropagation();

   $('body').bind("click",function() {
        $("#comment_btn_div_"+post_id).hide()
        $(this).unbind();
   });
});

我希望它对你有用。div comment_btn_div_48774是你身体的一部分。是的,它是车身的一部分,对我来说很好。你有错误吗?没有,我没有错误。请注意,我的页面中有许多表单。所以我做了$.comment\u btn.hide。为了使用此代码显示特定的注释按钮$comment\u btn\u div\u+post\u id.show;为什么要将点击事件绑定到.comment\u btn,这也是div的一部分。很抱歉,这段代码在Firefox中运行良好。但它在铬上还是一样的。第一次工作。第二次评论按钮没有出现。我已经更新了代码,请你点击。我不确定你的页面结构。因为我认为其他因素会阻碍它。在js中,代码运行良好。请你在文本区域单击和正文单击中添加警告进行检查。。单击是否有效。调用是否将发生。使用示例$'.comment_txt'.blurfunction{alert1;}更新了我的问题;模糊不工作在铬。我没有收到这个代码的警报。这个节目很成功。这是我的Chrome版本23.0.1271.97。使用Ubuntu。
var post_id=null;
$(document).on('click', ".comment_txt, .comment_btn", function(event) {
  post_id = $(this).attr("post-id");      
   $("#comment_btn_div_"+post_id).show();
   event.stopPropagation();

   $('body').bind("click",function() {
        $("#comment_btn_div_"+post_id).hide()
        $(this).unbind();
   });
});