jQuery實(shí)現(xiàn)輸入框下拉列表樹插件特效代碼分享
本文實(shí)例講述了jQuery實(shí)現(xiàn)輸入框下拉列表樹插件。分享給大家供大家參考。具體如下:
這是一款基于jquery實(shí)現(xiàn)的下拉列表樹插件源碼,是一款實(shí)用的jquery 樹形下拉框下拉樹代碼。點(diǎn)擊文本框即可彈出樹形下拉列表,單擊列表項(xiàng)即可選中列表對(duì)應(yīng)文字,是一款非常實(shí)用的特效源碼。
運(yùn)行效果圖: -------------------查看效果 下載源碼-------------------

小提示:瀏覽器中如果不能正常運(yùn)行,可以嘗試切換瀏覽模式。
為大家分享的jQuery實(shí)現(xiàn)輸入框下拉列表樹插件代碼如下
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery實(shí)現(xiàn)輸入框下拉列表樹插件代碼</title>
<link href="css/dtreeck.css" type="text/css" rel="stylesheet" />
</head>
<body>
<!--代碼部分begin-->
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="1" valign="top" width="35%" style="padding-left: 30px;">
</td>
<td valign="top" height="65%" align="left">
<form method="post" id="regform">
<table width="70%" cellpadding="1" cellspacing="0" border="0" style="margin-top: 10px;">
<tr>
<td width="20%" align="right">
父 菜 單:
</td>
<td width="30%" align="left">
<input type="text" id="menu_parent_name" style="width: 150px;">
<input type="hidden" id="menu_parent" name="menu_parent">
<input type="hidden" id="oprate" name="oprate">
<input type="hidden" id="menu_id" name="menu_id">
</td>
<td width="20%" align="right">
</td>
<td width="30%" align="left">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script src="http://www.lanrenzhijia.com/ajaxjs/jquery.min.js"></script>
<script src="js/dtreeck.js"></script>
<div id="treediv">
<div align="right">
<a href="javascript:viod(0);" id="closed"><font color="#000">關(guān)閉</font></a>
</div>
<script src="js/lanren.js"></script>
</div>
<script>
//生成彈出層的代碼
<!-- 彈出層-->
xOffset = 0;//向右偏移量
yOffset = 25;//向下偏移量
var toshow = "treediv";//要顯示的層的id
var target = "menu_parent_name";//目標(biāo)控件----也就是想要點(diǎn)擊后彈出樹形菜單的那個(gè)控件id
$("#"+target).click(function (){
$("#"+toshow)
.css("position", "absolute")
.css("left", $("#"+target).position().left+xOffset + "px")
.css("top", $("#"+target).position().top+yOffset +"px").show();
});
//關(guān)閉層
$("#closed").click(function(){
$("#"+toshow).hide();
});
//判斷鼠標(biāo)在不在彈出層范圍內(nèi)
function checkIn(id){
var yy = 20; //偏移量
var str = "";
var x=window.event.clientX;
var y=window.event.clientY;
var obj=$("#"+id)[0];
if(x>obj.offsetLeft&&x<(obj.offsetLeft+obj.clientWidth)&&y>(obj.offsetTop-yy)&&y<(obj.offsetTop+obj.clientHeight)){
return true;
}else{
return false;
}
}
//點(diǎn)擊body關(guān)閉彈出層
$(document).click(function(){
var is = checkIn("treediv");
if(!is){
$("#"+toshow).hide();
}
});
<!-- 彈出層-->
//生成彈出層的代碼
//點(diǎn)擊菜單樹給文本框賦值------------------菜單樹里加此方法
function setvalue(id,name){
$("#menu_parent_name").val(name);
$("#menu_parent").val(id);
$("#treediv").hide();
}
</script>
<!--代碼部分end-->
</body>
</html>
以上就是為大家分享的jQuery實(shí)現(xiàn)輸入框下拉列表樹插件代碼,希望大家可以喜歡。
相關(guān)文章
jquery彈窗插件colorbox綁定動(dòng)態(tài)生成元素的方法
這篇文章主要介紹了jquery彈窗插件colorbox綁定動(dòng)態(tài)生成元素的方法,colorbox是一款非常好用的彈窗插件,需要的朋友可以參考下2014-06-06
jQuery-1.9.1源碼分析系列(十一)DOM操作續(xù)之克隆節(jié)點(diǎn)
這篇文章主要介紹了jQuery-1.9.1源碼分析系列(十一)DOM操作續(xù)之克隆節(jié)點(diǎn)的相關(guān)資料,需要的朋友可以參考下2015-12-12
jquery序列化表單以及回調(diào)函數(shù)的使用示例
使用jQuery提供的表單序列化方法可以很好的解決JSP表單中一個(gè)個(gè)傳值的問(wèn)題,下面有個(gè)示例,大家可以參考下2014-07-07
jquery實(shí)現(xiàn)走馬燈特效實(shí)例(撲克牌切換效果)
本文主要介紹了jquery實(shí)現(xiàn)走馬燈特效實(shí)例(撲克牌切換效果),文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02
jQuery EasyUI 菜單與按鈕之創(chuàng)建簡(jiǎn)單的菜單和鏈接按鈕
這篇文章主要介紹了jQuery EasyUI 菜單與按鈕之創(chuàng)建簡(jiǎn)單的菜單和鏈接按鈕,需要的朋友可以參考下2015-11-11
jQuery中noconflict函數(shù)的實(shí)現(xiàn)原理分解
這篇文章主要介紹了jQuery中noconflict函數(shù)的實(shí)現(xiàn)原理分解,noconflict是用來(lái)防止變量沖突的,本文就分解了它的實(shí)現(xiàn)原理,并分析了它的實(shí)現(xiàn)源碼,需要的朋友可以參考下2015-02-02
jQuery彈出層始終垂直居中相對(duì)于屏幕或當(dāng)前窗口
碰到?jīng)]有固定高或者固定寬或者固定高和寬的時(shí)候,我們就需要用JS去處理,去動(dòng)態(tài)獲取當(dāng)前窗口高或者寬;今天弄了2種情況,一個(gè)是相對(duì)于屏幕窗體,一個(gè)是相對(duì)于當(dāng)前的窗口,看代碼2013-04-04
jQuery+css實(shí)現(xiàn)的換頁(yè)標(biāo)簽欄效果
這篇文章主要介紹了jQuery+css實(shí)現(xiàn)的換頁(yè)標(biāo)簽欄效果,涉及jQuery動(dòng)態(tài)操作頁(yè)面元素構(gòu)造換頁(yè)標(biāo)簽的相關(guān)技巧,需要的朋友可以參考下2016-01-01

