成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

讓圖片也能實(shí)現(xiàn)radio的Label功能

2011-05-06 17:57:24來源:西部e網(wǎng)作者:

在網(wǎng)頁中填寫表單是,單選、多選等input按鈕可以用label的for屬性實(shí)現(xiàn)點(diǎn)擊文字即可實(shí)現(xiàn)選擇。那么如果input radio或者input check旁邊不是文字而是圖片呢?其實(shí)也可以實(shí)現(xiàn)的,不過要加上一點(diǎn)JavaScript代碼了。

在網(wǎng)頁中填寫表單是,單選、多選等input按鈕可以用label的for屬性實(shí)現(xiàn)點(diǎn)擊文字即可實(shí)現(xiàn)選擇。那么如果input radio或者input check旁邊不是文字而是圖片呢?其實(shí)也可以實(shí)現(xiàn)的,不過要加上一點(diǎn)JavaScript代碼了。

1、點(diǎn)擊文字實(shí)現(xiàn)選擇的效果

這個(gè)就是正常效果,不過也先介紹一下。

<input name="a1" id="a1" type="radio" /><label for="a1">西部E網(wǎng)(weste.net)</label>
<input name="a2" id="a2" type="radio" /><label for="a2">騰訊網(wǎng)(qq.com)</label>

這里用到label標(biāo)簽的for屬性,內(nèi)容與input的id相同即可。

2、點(diǎn)擊圖片實(shí)現(xiàn)選擇的效果

<label onclick="this.getElementsByTagName('input')[0].checked=true" style="cursor:hand"><input name="a1" id="a1" type="radio" /><img src="http://www.wsalc.com/images/logo.png"></label>
<label onclick="this.getElementsByTagName('input')[0].checked=true" style="cursor:hand"><input name="a1" id="a1" type="radio" /><img src="http://www.wsalc.com/images/logo.png"></label>

\

這樣就實(shí)現(xiàn)了讓圖片也能實(shí)現(xiàn)radio的Label功能。
 

關(guān)鍵詞:htmljavascriptLabel

贊助商鏈接:

主站蜘蛛池模板: 福建省| 陇南市| 开江县| 汨罗市| 二连浩特市| 阳山县| 泰顺县| 平乡县| 江口县| 贵阳市| 洮南市| 夏邑县| 威信县| 镇安县| 两当县| 阳泉市| 扎兰屯市| 广饶县| 绥阳县| 新化县| 通榆县| 锦屏县| 溆浦县| 交城县| 易门县| 彰武县| 广河县| 游戏| 南通市| 同心县| 巴彦淖尔市| 越西县| 盐城市| 宁安市| 闽侯县| 天镇县| 通道| 湖南省| 双鸭山市| 木兰县| 柏乡县|