jqueryのcloneでtable要素ごとコピーしたいのですが、その際name属性も変更したいのですが、tableの子要素の名前属性はどのように変更したら良いのでしょうか。
例:name=event_name_01のようにしたいです。。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script> <script> $(function () { var i = 0; $('.add_button').click(function(){ i++; $( "#clone_id" ). clone(). appendTo( "#divid" ); }); }); </script> </head> <body> <form name="form1" method="post" action=""> <div id="divid"> <table class="table_sample" id="clone_id"> <tr> <th>日程</th> <td><input type="text" name="event_name" value="" class="time"/></td> </tr> <tr> <th>会場</th> <td><input type="text" name="text_name" value="" /></td> </tr> <tr> <th>radio</th> <td> <input type="radio" name="radio1" value="0"> <input type="radio" name="radio2" value="1"> <input type="radio" name="radio3" value="2"> </td> </tr> <tr> <th>checkbox</th> <td> <input type="checkbox" name="chekbox1" value="0"> <input type="checkbox" name="chekbox2" value="1"> <input type="checkbox" name="chekbox3" value="2"> </td> </tr> </table> </div> <input type="button" name="button" value="追加" class="add_button"> <input type='submit' value='送信'> </form> </body> </html>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/04 07:55
2016/08/04 07:58