こんにちは私は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>
私がやりたいのは、ユーザーに作成するアイテムの種類に名前を付けてもらうことです。彼らがパラメータのリストを入力できるようになった後。「タイプ」ごとにパラメーターの数が異なるため、ボタンをクリックして、新しい入力セットを追加できるようにしたいと思います。ボタンをクリックすると、入力が表示されてから消えます...
あなたはほとんどそれを手に入れました。ボタンとスクリプトタグをフォームから取り出して、次のように下部に配置するだけです。
<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]
コメントを追加