小编jak*_*123的帖子

在div区域外单击时关闭div

我有这段代码.我正在尝试关闭div,当在Div之外点击时,我已经搜索了这个论坛但找不到解决方案 - 这是一个小提琴 - 演示

$('#hideshow1').on("click", function() {
    var text = $(this).val();
    $("#req").toggle();

});

$(window).on("click keydown", function(e) {
  //e.preventDefault() /*For the Esc Key*/
  if (e.keyCode === 27 || !$(e.target).is(function() {return $("#req, #hideshow1")})) {
    $("#req").hide()
  }
}).focus()
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
1
解决办法
224
查看次数

将数据发布到sql数据库而不重新加载页面

问题是我无法在没有重新加载的情况下在我的数据库中插入数据我已经测试了它没有note_sql.js和我的note_sql.php工作正常但是我的js文件中似乎有问题,如果有些身体可以指向我正确的方向它会很棒

的index.php

    <form id="noteform" action="note_sql.php" method="POST">
    <input type="text" name="note"></input>
    <input id="sub" type="submit" value="Save Note" />
    </form>
    <span id="result_note"><span>
   <script type ="text/javascript" src="jquery/note_sql.js"></script>
Run Code Online (Sandbox Code Playgroud)

note_sql.js

$("#sub").click(function(){

var data = $("#noteform: input").serializeArray();
$.post($("#noteform").attr("action"),data,function(info){$("result_note").html(info); });
    clearInput();
}); 

$("#noteform").submit(function(){
    return false;
});

function clearInput(){
    $("#noteform :input").each(function(){
        $(this).val('');
    });
}
Run Code Online (Sandbox Code Playgroud)

php jquery

3
推荐指数
1
解决办法
1045
查看次数

无法附加jquery

我无法附加页面只是似乎刷新我想要查看它而不刷新页面

的index.php

<div class="view_comment">
        <b>username :</b> <?php echo  $comment_comment;?>
</div> 
<div id="comment_type_area" class="comment_type_area">
        <form method="POST">
            <input type="text" class="comment" post_id="<?php echo $shared_id2; ?>" id="text_comment" placeholder="Write a Comment"></input>
            <input type="submit" id="post_button" ></input> 
        </form>
        </div>
Run Code Online (Sandbox Code Playgroud)

的jquery.js

  $(document).ready(function(){

        $('.comment').keydown(function (e){
            if(e.keyCode == 13){
                var post_id = $(this).attr('post_id');
                var comment = $(this).val();
                $.post('/comment.php',{ post_id: post_id, comment:comment});
                $('.comment').val('');
/*i am guessing the problem starts from here and onwards*/
                $(this).parent().children('.comments').append("<div class='view_comment'><b>Username :</b>" + comment +"</div>");
            }
        });

    });
Run Code Online (Sandbox Code Playgroud)

javascript php jquery

2
推荐指数
1
解决办法
183
查看次数

标签 统计

jquery ×3

php ×2

javascript ×1