![](/img/trans.png)
[英]Jquery-Mobile: how to enable select tag using name attribute in external java script
[英]Jquery-Mobile: How to call the external java script function from html
我是JQM的新手。 我想從html調用外部Java腳本函數。 為此,我在外部標簽中包括了這樣的外部javascript文件。
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Single page template</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" type="text/css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="food_exercise.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head>
我正在這樣調用外部JS函數。 在這里,我收到類似scipt標簽無效位置的錯誤。 更改選擇標記中的數據時如何調用外部JS函數? 請任何人可以幫助我
<div data-role="content">
<div>
<select onchange="set_FRE(this,Item_Activity,Qty_Time)" size="1" name="choice">
<option value="" selected="selected">SELECT Food/Exercise</option>
<script type="text/javascript">
setChoice(this);
</script>
</select>
<select name="Item_Activity" size="1" disabled="disabled" onchange="set_item_activity(this,Qty_Time)"></select>
<select name="Qty_Time" size="1" disabled="disabled" onchange="print_IE_QT(Item_Activity,this)"></select>
</div>
</div>
您需要注意不要將腳本標記放在Smamatti提到的無效位置。 您還應該在文檔的末尾或與文檔加載功能一起在文檔的開頭加載腳本標簽。 這樣做的原因是您不希望javascript代碼在沒有html標簽的情況下顯示在您擁有它的位置,所以該腳本如何期望在尚不存在的東西上運行?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.