我正在尝试包含以下jquery库:
http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
当我运行波纹管代码警报时不显示:
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form id="payment_form" action="https://arembepe.net/Tester3.php" method="POST">
Número do cartão: <input type="text" id="card_number"/>
<br/>
</form>
</div>
<script src="https://assets.pagar.me/js/pagarme.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
alert(123);
</script>
但是,当我在没有引用jquery库的情况下运行相同的代码时,会显示警告:
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form id="payment_form" action="https://arembepe.net/Tester3.php" method="POST">
Número do cartão: <input type="text" id="card_number"/>
<br/>
</form>
</div>
<script src="https://assets.pagar.me/js/pagarme.min.js"></script><script>
alert(123);
</script>
阅读评论后,我将代码更改为:
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form id="payment_form" action="https://arembepe.net/Tester3.php" method="POST">
Número do cartão: <input type="text" id="card_number"/>
<br/>
</form>
</div>
<script src="https://assets.pagar.me/js/pagarme.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
alert($("#card_holder_name").val());
</script>
使用这个新代码,我设法显示警报(123)。但是当我尝试使用警报时($(&#34;#card_holder_name&#34;)。val());我得到&#34; ReferenceError:$未定义&#34;我无法使用任何jquery函数。
答案 0 :(得分:0)
你试过了吗?
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form id="payment_form" action="https://arembepe.net/Tester3.php" method="POST">
Número do cartão: <input type="text" id="card_number"/>
<br/>
</form>
</div>
<script src="https://assets.pagar.me/js/pagarme.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
alert(123);
</script>
修改:这可以正常运行:
<!DOCTYPE doctype html>
<html>
<head>
</head>
<script src="https://assets.pagar.me/js/pagarme.min.js">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
alert(123);
</script>
<body>
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form action="https://arembepe.net/Tester3.php" id="payment_form" method="POST">
Número do cartão:
<input id="card_number" type="text"/>
<br/>
</form>
</div>
</body>
</html>
答案 1 :(得分:0)
在这一行:
<script src="https://assets.pagar.me/js/pagarme.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
alert(123);
</script>
您忘记了结尾和启动脚本标记。纠正它:
<script src="https://assets.pagar.me/js/pagarme.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
alert(123);
</script>
答案 2 :(得分:0)
如果您放置一个脚本源,该标记只会在该源处运行脚本,因此您只需添加第三个脚本标记。你的代码:
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form id="payment_form" action="https://arembepe.net/Tester3.php" method="POST">
Número do cartão: <input type="text" id="card_number"/>
<br/>
</form>
</div>
<script src="https://assets.pagar.me/js/pagarme.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
alert(123);
</script>
应该成为这个:
<div style="float: left; margin-left:0px; width:20px; padding-top: 10px;">
<form id="payment_form" action="https://arembepe.net/Tester3.php" method="POST">
Número do cartão: <input type="text" id="card_number"/>
<br/>
</form>
</div>
<script src="https://assets.pagar.me/js/pagarme.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
alert(123);
</script>
答案 3 :(得分:0)
在<script src="url"></script>
src
属性是可选的。如果它存在,则其值为url
,用于标识.js
文件。
<script src="url">
和</script>
之间的内容应为空白。
如果它包含somethings.it被忽略
如果src
属性不存在,则编译并执行<script>
和</script>
之间的内容文本。