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>
2019-07-03
在<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ù)。
此時(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ù)。
此時(shí),只有點(diǎn)擊按鍵“確定1”才會(huì)觸發(fā)openwin()函數(shù)打開網(wǎng)頁,點(diǎn)擊其他位置則無此效果。
2018-11-27
form是整個(gè)表單標(biāo)簽,而input是表單中任意一個(gè)標(biāo)簽,onclick事件是加在需要被點(diǎn)擊的標(biāo)簽上的。
2018-10-02
你的意思是在form里面加載和不在form里面加載的區(qū)別嗎