[英]2 Different Javascripts - Only 1 Works at a Time
我在一頁上有2個腳本,一次只能工作一個。 我對使用javascript不太熟悉,所以希望這是一個簡單的解決方法。 在嘗試尋找答案之后,我決定最好只是詢問並提出我的代碼。
任何建設性的意見和答案表示贊賞。 謝謝。
先感謝您。
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<body>
<script>
$(function () {
$("#tabs").tabs({
collapsible: true
});
});
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Tab 1</a>
</li>
<li><a href="#tabs-2">Tab 2</a>
</li>
<li><a href="#tabs-3">Tab 3</a>
</li>
</ul>
<div id="tabs-1">
<p><strong>Click this tab again to close the content pane.</strong>
</p>
<p>Content 1</p>
</div>
<div id="tabs-2">
<p><strong>Click this tab again to close the content pane.</strong>
</p>
<p>Content2</p>
</div>
<div id="tabs-3">
<p><strong>Click this tab again to close the content pane.</strong>
</p>
<p>Content 3</p>
</div>
</div>
<script language="javascript" type="text/javascript">
document.write('<script language="javascript" src="http://www.example.com/test.js"><\/script>');
</script>
</body>
第一個腳本看起來不錯,第二個腳本則不好。 通過將其寫入文檔不會立即執行...
就是這樣:
<script type="text/javascript" src="http://www.example.com/test.js"></script>
但是,更詳細的錯誤描述對於更快,更專業的幫助將很有用。 我們怎么知道什么不正常? 我只是根據您在此處提供的代碼猜測什么是行不通的。
test.js應該做什么?
@編輯:
如果第二個腳本正常工作,我仍然建議按照上面的解釋進行操作...
如果第一個腳本不起作用,可以這樣做:
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs({
collapsible: true
});
});
</script>
這樣,就不會執行第一個腳本,因為您將其放在函數中並且從未調用過它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.