第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

onclick加載from里面和input里面有什么區(qū)別

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>單擊事件 </title>

<script type="text/javascript">

? function openwin(){

? ? ?window.open('http://idcbgp.cn','_blank','height=600,width=400,top=100,toolbar=no,left=0,menubar=no,scrollbars=no,status=no');}

</script>

</head>

<body>

? <form>

? ? <input name="點(diǎn)擊我" type="button" value="點(diǎn)擊我" onclick="openwin()"/>

? </form>

</body>

</html>



正在回答

3 回答

在<form>中和在<input>中關(guān)聯(lián)onclick事件的函數(shù)openwin()還是有所區(qū)別的。為了方便說明,我修改了示例HTML程序,加入了2個(gè)<input type="button">。通過下面的代碼說明區(qū)別:

一、在<form>中加入onclick屬性

作用:在點(diǎn)擊表單<form>范圍內(nèi)任意位置都會(huì)觸發(fā)openwin()函數(shù)。

<script>
????<form?onclick="openwin()">
????????<input?type="button"?value="確定1"?/>
????????<input?type="button"?value="確定2"?/>
????</form>
</script>

此時(shí),無論點(diǎn)擊哪個(gè)按鍵都會(huì)觸發(fā)openwin()函數(shù)打開網(wǎng)頁。甚至在兩個(gè)按鍵中間的空白位置點(diǎn)擊鼠標(biāo)也會(huì)觸發(fā)openwin()函數(shù)。因?yàn)椋瑑蓚€(gè)按鍵之間的空白位置也屬于這個(gè)<form>的范圍之內(nèi)。

二、在<input>中加入onclick屬性

作用:只有在點(diǎn)擊對應(yīng)的按鍵<input type="button">時(shí)才會(huì)觸發(fā)openwin()函數(shù)。

<script>
????<form>
????????<input?type="button"?value="確定1"?onclick="openwin()"?/>
????????<input?type="button"?value="確定2"?/>
????</form>
</script>

此時(shí),只有點(diǎn)擊按鍵“確定1”才會(huì)觸發(fā)openwin()函數(shù)打開網(wǎng)頁,點(diǎn)擊其他位置則無此效果。

4 回復(fù) 有任何疑惑可以回復(fù)我~

form是整個(gè)表單標(biāo)簽,而input是表單中任意一個(gè)標(biāo)簽,onclick事件是加在需要被點(diǎn)擊的標(biāo)簽上的。

0 回復(fù) 有任何疑惑可以回復(fù)我~

你的意思是在form里面加載和不在form里面加載的區(qū)別嗎

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

onclick加載from里面和input里面有什么區(qū)別

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號