jQuery动态表单字段添加
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery动态表单字段添加相关的知识,希望对你有一定的参考价值。
I wrote this very quickly for a form I parse that allows a user to send a page to up to 5 friends. The script adds a click event to an image of a + sign beside an input box. When clicked if the user hasn't already added 5 friends to email, additional email boxes will be added.
$(function() { var fieldCount = 1; $("#addFieldButton").click(function() { fieldCount++; if(fieldCount <= 5) { var fieldID = "recipient_email_" + fieldCount; $("#additionalEmails").append("<label for='"+fieldID+"'>Recipient Email "+fieldCount+": </label>"+ "<input type='text' name='"+fieldID+"' " + "id='"+fieldID+"' size='30'><br />" ); } else { alert("Maximum email fields reached."); } }); }); </script>
以上是关于jQuery动态表单字段添加的主要内容,如果未能解决你的问题,请参考以下文章
Jquery -> php -> mysql 和动态表单字段