Jquery 表格提交不';t与相对定位的div一起工作
我在Jquery 表格提交不';t与相对定位的div一起工作,jquery,forms,Jquery,Forms,我在div中有一个HTML,当我们点击(框架顶部的黑色背景)时,jQuery/CSS会显示位置:relative jQuery工作得很好,但是当您单击时,什么也没有发生。数据不会发送到php文件进行处理 我尝试了GET和POST方法,没有 我在这里做了一个JSFiddle: HTML: CSS: 您的事件正在冒泡,因此单击按钮返回false。。 要修复此添加事件,请阻止传播 我还更新了要使用的代码。在上,而不是。单击 删除返回false在您的JavaScript代码中,它工作得很好 希望此帮
div
中有一个HTML
,当我们点击
(框架顶部的黑色背景)时,jQuery/CSS会显示位置:relative
jQuery工作得很好,但是当您单击
时,什么也没有发生。数据不会发送到php文件进行处理
我尝试了GET和POST方法,没有
我在这里做了一个JSFiddle:
HTML:
CSS:
您的事件正在冒泡,因此单击按钮返回false。。 要修复此添加事件,请阻止传播 我还更新了要使用的代码。在上,而不是。单击
删除
返回false代码>在您的JavaScript代码中,它工作得很好
希望此帮助请在发布后随时回来校对您的作品。。。您的所有内联代码对我们都是不可见的,因为您未能对其进行格式化。这并不能提供问题的答案。若要评论或要求作者澄清,请在其帖子下方留下评论-您可以随时在自己的帖子上发表评论,一旦您有足够的评论,您就可以发表评论。@Ayush-这看起来像是对我的回答。。。这可能不是你同意的答案,但它试图回答这个问题。
<div id="container">
<div id="news" class="hidden">
<article>
<form action="form-news.php" method="post" id="form-news">
<label for="news-name">Name :</label>
<input type="text" id="news-name" name="news-name">
<input type="submit" name="submit-news" value="Ok" id="submit-news">
</form>
<div id="news_added"></div>
</article>
<br class="clear">
</div><br class="clear">
</div>
$(document).ready( function() {
$("#container").click(function(){
$("#news").removeClass("hidden");
return false;
});
});
#container{background:black; position:relative;}
#news{position:absolute; top:100px; left:50px;}
.clear{clear:both;}
.hidden{display:none;}
$(document).ready(function () {
$("body").on('click', '#container', function (e) {
console.log("hit"); //check the log you will see that even the input will trigger this console.log.
e.preventPropagation; //this stops bubbling.
if (!$(e.target).is(':input')) { //maybe you want to check if the DIV is the only thing clicked? here is where to do this.
$("#news").removeClass("hidden");
return false;
}
});
});