js實現(xiàn)帶有介紹的Select列表菜單實例
本文實例講述了js實現(xiàn)帶有介紹的Select列表菜單。分享給大家供大家參考。具體如下:
帶有介紹的Select列表菜單特效代碼,并不是導航菜單,這是表單中常用的下拉列表菜單,里面定義的菜單名稱和鏈接都可以自己修改,不同的是添加了一個說明功能,鼠標點擊列表中內容的時候,會浮動出本條內容的介紹,另外文本框內的內容也會跟著改變。
運行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-info-select-menu-codes/
具體代碼如下:
<html> <head> <title>帶有說明的導航欄</title> </head> <body> <script language="JavaScript"> <!-- function herfto(){ if (document.stationform.refsel.options[0].selected){ //根據(jù)用戶選定的項目 window.location.href = "http://www.dbjr.com.cn";} //改變本窗口的地址 else if (document.stationform.refsel.options[1].selected) { window.location.;} else if (document.stationform.refsel.options[2].selected) { window.location.;} else if (document.stationform.refsel.options[3].selected) { window.location.;} else if (document.stationform.refsel.options[4].selected) { window.location.;} else if (document.stationform.refsel.options[5].selected) { window.location.;} else if (document.stationform.refsel.options[6].selected) { window.location.;} //根據(jù)可選條目,這里應該相應的增減。 return true; } function textValue(){ var stationInteger, stationString stationInteger=document.stationform.refsel.selectedIndex //取得選定項目的編號 stationString=document.stationform.refsel.options[stationInteger].title //根據(jù)編號取得相應說明 document.stationform.stationtext.value = stationString } //將說明顯示出來 //--> </script> <form name="stationform"> <select name="refsel" onChange="textValue()" multiple size="5"> <option title="一個提供優(yōu)質腳本代碼的網站">腳本之家 <option title="相當不錯的虛擬社區(qū)">新浪sina <option title="不用說,要搜索來這里就對了">搜狐 <option title="提供免費個人主頁空間">網易163 <option title="一個優(yōu)秀的學生網站">世紀學苑 <option title="首創(chuàng)同學錄,中國學生的聚會場所">中國人 <option title="世界聞名的搜索巨頭">雅虎yahoo </select> <p> <input type="button" name="stationbutton" value="Go!" onClick="herfto()" style="background-color: #FFFFFF; border: 1 solid #000000"> <p><input type="text" name="stationtext" value="" size="30" maxlength="35" style="border: 1 solid #000000"> </form> </body> </html>
希望本文所述對大家的javascript程序設計有所幫助。
相關文章
TypeScript之元組、數(shù)組及as?const的使用
TypeScript中的元組、數(shù)組和as?const關鍵字對于類型安全性和代碼可讀性非常重要,本文主要介紹了TypeScript之元組、數(shù)組及as?const的使用,感興趣的可以了解一下2023-10-10深入理解JavaScript字節(jié)二進制知識以及相關API
當前,前端對二進制數(shù)據(jù)有許多的API可以使用,這豐富了前端對文件數(shù)據(jù)的處理能力,有了這些能力,就能夠對圖片等文件的數(shù)據(jù)進行各種處理。本文將著重介紹一些前端二進制數(shù)據(jù)處理相關的API知識,希望對大家有所幫助2023-02-02javascript 刪除dom對象的事件函數(shù)代碼
本文為《JavaScript高級程序設計》第9章中的跨平臺事件中的部分內容。2010-04-04獲取URL地址中的文件名和參數(shù)的javascript代碼
JS 獲取URL地址中的文件名和參數(shù),這個版本中有詳細的注釋。2009-09-09