[英]jQuery : Element not defined error (but defined)
I have some form in my page,it forms does not hard code, 我的页面中有一些表格,它没有硬编码,
All forms have a name and unique ID. 所有表格都有名称和唯一ID。
But when calling that forms,console sat NOT DEFINED. 但是在调用该表格时,控制台没有被定义。
I want submit forms with jQuery,but forms not defined, 我想用jQuery提交表单,但表单未定义,
I tried with: 我尝试过:
alert(jQuery("#paypal_form_-5").length);
//output is 0
and 和
document.getElementById('paypal_form_-5').submit();
and etc.. But does not work....... 等。但是不起作用.....
form code 表格代码
<form target="_blank" action="https://www.paypal.com/cgi-bin/webscr" name="paypal_form_-5" id="paypal_form_-5" method="POST">
<input type="hidden" value="http://www.domain.com/2014/index.php?option=domain&view=addon_payments&type=return" name="return">
<input type="hidden" value="2" name="rm">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="rajnvr@rctech.org" name="business">
<input type="hidden" value="USD" id="paypal_form_currency_code_-5" name="currency_code">
<input type="hidden" value="http://www.domain.com/2014/index.php?option=domain&view=addon_payments&type=cancel" name="cancel_return">
<input type="hidden" value="http://www.domain.com/2014/components/domain/views/addon_payments/paypal_ipn.php" name="notify_url">
<input type="hidden" value="GOLD Membership" name="item_name">
<input type="hidden" value="20" id="paypal_form_amount_-5" name="amount">
<input type="hidden" value="http://www.domain.com/2014/components/domain/views/addon_payments/paypal_ipn.php" name="notify_url">
<input type="hidden" value="001" name="item_number">
<input type="hidden" value="2740" name="custom">
<span id="paypal_price_title_-5" class="paypal_price_title">GOLD Membership 20 USD</span>
<input type="button" onclick="send_request_to_paypal_express(-5);" value="Pay" name="button_-5">
</form>
Add the JS bellow your HTML or wrap your JS by 在您的HTML下方添加JS或通过以下方式包装JS:
$(document).ready(function(){/*Your code*/});
Demo: http://jsfiddle.net/4c9p7/ 演示: http : //jsfiddle.net/4c9p7/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.