我在mailchimp弹出式订阅表单上通过javascript模拟点击时出现问题,我需要你的帮助。
<!-- Title & Description - Holds HTML from CK editor -->
<div class="content__titleDescription" data-dojo-attach-point="descriptionContainer"><strong>Unlock the content </strong>by subscribing to our page.</div>
<!-- Form Fields -->
<form action="//mc.us7.list-manage.com/subscribe/form-post?u=bcd9828fa83ea7a231ffbee26&id=1928481ac4" accept-charset="UTF-8" method="post" enctype="multipart/form-data" data-dojo-attach-point="formNode" novalidate="">
<div class="content__formFields" data-dojo-attach-point="formFieldsContainer">
<div class="field-wrapper" id="uniqName_3_0" widgetid="uniqName_3_0">
<label for="mc-EMAIL">Email Address</label>
<input type="text" name="EMAIL" value="" id="mc-EMAIL" class="invalid">
<div class="invalid-error" style="display: block;">This field is required.</div>
</div>
<div class="field-wrapper" id="uniqName_3_1" widgetid="uniqName_3_1">
<label for="mc-FNAME">First Name</label>
<input type="text" name="FNAME" value="" id="mc-FNAME" class="valid">
<div class="invalid-error" style="display: none;"></div>
</div>
<div style="position:absolute;left:-5000px;">
<input type="text" name="b_bcd9828fa83ea7a231ffbee26_1928481ac4" tabindex="-1" value="">
</div>
</div>
<div class="content__button">
<input class="button" type="submit" value="Subscribe" data-dojo-attach-point="submitButton">
</div>
</form>
<!-- Footer - Holds HTML from CK editor -->
<div class="content__footer" data-dojo-attach-point="footerContainer"></div>
</div>
<div class="modalContent__image" data-dojo-attach-point="formImageContainer"></div>
我想要的目标代码是:
<input class="button" type="submit" value="Subscribe" data-dojo-attach-point="submitButton">
这是您可以在
中看到的提交按钮“订阅”http://www.aspeagro.com/EN_Program_Abricot.html
谢谢!
答案 0 :(得分:0)
将id="btn"
属性设置为您的提交按钮并使用jQuery,您可以通过$("#btn").click();
调用触发点击
答案 1 :(得分:0)
这个怎么样?我认为应该做你想做的事情?
<强> HTML 强>
<input id="submit-button" class="button" type="submit" value="Subscribe" data-dojo-attach-point="submitButton">
<强> JS 强>
$('#submit-button').on('click', function(e){
e.preventDefault();
// Do what you want to do
});
答案 2 :(得分:0)
如果您的目的是提交表单,请不要发送点击事件,但请使用表单的提交方式:
var form = document.getElementById('uniqName_3_0').parentNode.parentNode;
form.submit();
如果您为表单提供id属性,则代码当然更容易:
<form id="myform" ...
然后:
document.getElementById('myform').submit();
答案 3 :(得分:0)
该按钮位于iframe内。要从父页面访问它,您将触发它:
$('iframe').contents().find('input:submit').click()