我有一个带有表单的页面,我需要在某个 div 中获取 A 链接的所有 ID 属性,并在提交之前将这些属性附加到隐藏表单字段中的表单。我该怎么做?
IE
<form action="/myaction" id="myForm">
<div id="recipients">
<a id="1">recipient one</a>
<a id="2">recipient two</a>
<a id="3">recipient three</a>
</div>
<a href="javascript:void(0)" id="sendMail">Send</a>
</form>
<script>
//Capture form before sending
$("#sendMail").click( function() {
//Do something here to loop over the a tags in the recipients div,
//and add as a list to a new hidden form field
$('#myForm').trigger('submit');
});
</script>
有任何想法吗?