簡體   English   中英

從 html 中的另一個 javascript 調用函數

[英]Calling function from another javascript in html

我有一個調用此函數的 html 輸入按鈕

<button class="Go" onClick="go();" disabled><div class="inner first">Nah...Not Yet</div></button>

但是這個腳本是我在另一個 javascript 中創建的,它的代碼類似於這個名稱“test.js”

function go()
{
    window.location.href = 'https://google.com';   
}

為了調用這個函數,我應該如何輸入輸入按鈕的腳本類型?

你應該在你的 html 中添加一個標簽,一切都會好的

<script type="text/javascript" src="test.js">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM