<div class="signup">
<div class="popover-markup" >
<span class="trigger">
<a href="#" class="btn btn-primary btn-sm register" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> Register </a></br>
</span>
<div class="content hide content2" id="reg">
<form class="form-horizontal" id="formRegister" action="#" >
<div class="form-group form-group-md form-pic">
<i class="fa fa-pencil-square-o fa-3x" aria-hidden="true"></i>
</span>
</div>
<div class="form-group ">
<div class="col-sm-12">
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
<input class="form-control" type="text" name="name" id="name" required placeholder="Enter name">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input class="form-control" type="email" name="email" id="email" required placeholder="Email address">
</div>
</div>
</div>
<div class="form-group " >
<div class="col-sm-12">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input class="form-control" type="password" name="password" id="password" required placeholder="Password">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" onclick="registration()" class="btn btn-danger btn-sm register_in_button"> <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Register </button>
</div>
</div>
</form>
</div>
</div>
</div>
我想在jquery中序列化这个表单,但它没有显示任何值,这是我的jquery代码
var form = $('div.content2 #formRegister').serialize();
我做错了什么,有人可以帮助我吗?!
答案 0 :(得分:1)
它对我很有吸引力。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").text($("form").serialize());
});
});
</script>
</head>
<body>
<div class="signup">
<div class="popover-markup" >
<span class="trigger">
<a href="#" class="btn btn-primary btn-sm register" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> Register </a></br>
</span>
<div class="content hide content2" id="reg">
<form class="form-horizontal" id="formRegister" action="#" >
<div class="form-group form-group-md form-pic">
<i class="fa fa-pencil-square-o fa-3x" aria-hidden="true"></i>
</span>
</div>
<div class="form-group ">
<div class="col-sm-12">
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
<input class="form-control" type="text" name="name" id="name" required placeholder="Enter name">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input class="form-control" type="email" name="email" id="email" required placeholder="Email address">
</div>
</div>
</div>
<div class="form-group " >
<div class="col-sm-12">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input class="form-control" type="password" name="password" id="password" required placeholder="Password">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" onclick="registration()" class="btn btn-danger btn-sm register_in_button"> <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Register </button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
答案 1 :(得分:0)
简单您可以使用,
$(selector).serialize()//function
$(".signup").serialize();