嗨,我对jquery还是比较陌生,并且有一些困难。在过去的几个小时中,我一直在努力。
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
</head>
<body>
<form id = "params">
Type: <input id = "type" type = "text">
Parameters:<input type = "text">
Required: <input type = "checkbox" >
<button id = "addpa">Add Parameter</button>
<script>
$("#addpa").click(function() {
$("#params").append("Parameters:<input type = \"text\"><br>Required: <input type = \"checkbox\" >");
});
</script>
</form>
</body>
</html>
我想要做的是让用户名称他们正在创建的项目的类型。之后,他们可以输入参数列表。由于每种“类型”将具有不同数量的参数,因此我希望它们能够单击按钮并有机会添加一组新的输入。当我单击按钮时,输入会显示出来然后消失...
你差点就明白了。只需从表单中取出button和script标签,然后将它们放在底部,如下所示:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
</head>
<body>
<form id = "params">
Type: <input id = "type" type = "text">
Parameters:<input type = "text">
Required: <input type = "checkbox" >
</form>
<button id = "addpa">Add Parameter</button>
<script>
$("#addpa").click(function() {
$("#params").append("Parameters:<input type = \"text\"><br>Required: <input type = \"checkbox\" >");
});
</script>
</body>
</html>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句