欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js 自定義的聯(lián)動(dòng)下拉框

 更新時(shí)間:2010年02月07日 12:40:13   作者:  
一直都嫌下拉框這個(gè)html控件難看,之前弄了個(gè)<div><ul><li></li></ul></div>版的下拉框.

覺(jué)得這個(gè)下拉框已經(jīng)稍微能滿足美觀需求了,

 

這個(gè)是點(diǎn)出來(lái)的效果,寫(xiě)了鍵盤(pán)的方向鍵,回車,esc等 事件, 并且能根據(jù)頁(yè)面的底部距離判斷是否向上展示

今天弄了個(gè)聯(lián)動(dòng)的,順便貼部分代碼

效果預(yù)覽:

 

 以下代碼解決了ie6的兼容問(wèn)題

復(fù)制代碼 代碼如下:

$containerDivText.mousedown(function() {
setTimeout(
function() {
if ($newUl[0].style.display == 'block') {
$newUl.hide();
positionHideFix();
return false;
}
$containerDiv.focus();
//show list
$newUl.slideDown(100);
positionFix();
//when keys are pressed
document.onkeydown = function(e) {
if (e == null) { // ie
var keycode = event.keyCode;
} else { // everything else
var keycode = e.which;
}
//enter key or esc key pressed, hide list
if (keycode == 13 || keycode == 27) {
$newUl.hide();
positionHideFix();
return false;
}
}
}, 1);
//the function settimeout is used for ie6, because if you click the element where you hava focused on the element,
//ie6 would think you click it twice(2010-2-4)
});

以下代碼解決了下拉框事件定義功能匱乏問(wèn)題
代碼
復(fù)制代碼 代碼如下:

if (!opts.callbackfn) {
$newLi.click(function(e) {
var $clickedLi = jQuery(e.target),
text = $clickedLi.text();
//update counter
currentIndex = $newLi.index($clickedLi);
//remove all hilites, then add hilite to selected item
$newLi.removeClass('hiLite');
$clickedLi.addClass('hiLite');
setSelectText(text);
$newUl.hide();
$containerDiv.css('position', 'static'); //ie
});
} else {
$newLi.click(function(e) {
var $clickedLi = jQuery(e.target),
text = $clickedLi.text();
//update counter
currentIndex = $newLi.index($clickedLi);
//remove all hilites, then add hilite to selected item
$newLi.removeClass('hiLite');
$clickedLi.addClass('hiLite');
setSelectText(text);
$newUl.hide();
$containerDiv.css('position', 'static'); //ie
(opts.callbackfn)(this.value);
});
} //param callbackfn means you can define a event function from every li in the ul;(2010-2-4)

然后是頁(yè)面的應(yīng)用,

代碼
復(fù)制代碼 代碼如下:

<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#my-dropdown2").hide();
jQuery('#my-dropdown1').sSelect(
{ defaultText: "",
callbackfn: function(value) {
if (value == 1) {
jQuery("#my-dropdown2_list").parent().remove();
jQuery("#linkc_value").val(value);
return;
}
jQuery.getJSON(
'/Department.mvc/GetSubDepartment?DepartmentID=' + value,
function(list) {
jQuery("#my-dropdown2_list").parent().remove();
jQuery("#my-dropdown2").html("");
var temp = "";
temp += "<option value=''>請(qǐng)選擇部門(mén)</option>";
for (var i = 0; i < list.length; i++) {
temp += "<option value=" + list[i].DepartmentID + ">" + list[i].DepartmentName + "</option>";
}
jQuery("#my-dropdown2").html(temp);
jQuery("#my-dropdown2").show();
jQuery('#my-dropdown2').sSelect({
callbackfn: function(value) {
jQuery("#linkc_value").val(value);
}
});
}
);
}
}
);
// killErrors = function(){ return true; }
// window.onerror = killErrors;
});
function linkc() {
location.href = "/User.mvc/Front?DepartmentID=" + jQuery("#linkc_value").val();
}
</script>

這三塊只是部分
但是花的時(shí)間較多 其它代碼不貼了 有問(wèn)題留言吧。。。

相關(guān)文章

  • 詳解webpack4之splitchunksPlugin代碼包分拆

    詳解webpack4之splitchunksPlugin代碼包分拆

    這篇文章主要介紹了詳解webpack4之splitchunksPlugin代碼包分拆,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-12-12
  • stats.js使用性能監(jiān)控源碼解讀

    stats.js使用性能監(jiān)控源碼解讀

    這篇文章主要為大家介紹了stats.js使用性能監(jiān)控源碼解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-04-04
  • ES6新特性之?dāng)?shù)組、Math和擴(kuò)展操作符用法示例

    ES6新特性之?dāng)?shù)組、Math和擴(kuò)展操作符用法示例

    這篇文章主要介紹了ES6新特性之?dāng)?shù)組、Math和擴(kuò)展操作符用法,結(jié)合實(shí)例形式分析了ES6中數(shù)組、Math和擴(kuò)展操作符的新特性、使用方法及相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2017-04-04
  • 解決js圖片加載時(shí)出現(xiàn)404的問(wèn)題

    解決js圖片加載時(shí)出現(xiàn)404的問(wèn)題

    這篇文章主要為大家詳細(xì)介紹了解決js圖片加載時(shí)出現(xiàn)404問(wèn)題的方法,具有一定的參考價(jià)值,這方面有困惑的朋友可以參考一下
    2015-11-11
  • JS調(diào)用CS里的帶參方法實(shí)例

    JS調(diào)用CS里的帶參方法實(shí)例

    js調(diào)用CS里的方法有很多,我用一種簡(jiǎn)單的方法,如下,有需要的朋友可以參考一下
    2013-08-08
  • javaScript實(shí)現(xiàn)浮點(diǎn)數(shù)轉(zhuǎn)十六進(jìn)制字符

    javaScript實(shí)現(xiàn)浮點(diǎn)數(shù)轉(zhuǎn)十六進(jìn)制字符

    浮點(diǎn)數(shù)轉(zhuǎn)十六進(jìn)制的方法有很多,在本文將為大家詳細(xì)介紹下js中時(shí)如何實(shí)現(xiàn)的,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下,希望對(duì)大家有所幫助
    2013-10-10
  • Three.js利用頂點(diǎn)繪制立方體的方法詳解

    Three.js利用頂點(diǎn)繪制立方體的方法詳解

    最近在學(xué)習(xí)three.js,將學(xué)習(xí)中遇到的知識(shí)點(diǎn)總結(jié)分享出來(lái),下面這篇文章主要給大家介紹了關(guān)于Three.js利用頂點(diǎn)繪制立方體的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來(lái)一起看看吧。
    2017-09-09
  • 200行代碼實(shí)現(xiàn)blockchain 區(qū)塊鏈實(shí)例詳解

    200行代碼實(shí)現(xiàn)blockchain 區(qū)塊鏈實(shí)例詳解

    這篇文章主要介紹了200行代碼實(shí)現(xiàn)blockchain 區(qū)塊鏈的相關(guān)知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧
    2018-03-03
  • javascript實(shí)現(xiàn)回到頂部特效

    javascript實(shí)現(xiàn)回到頂部特效

    當(dāng)頁(yè)面特別長(zhǎng)的時(shí)候,用戶想回到頁(yè)面頂部,必須得滾動(dòng)好幾次滾動(dòng)鍵才能回到頂部,如果在頁(yè)面右下角有個(gè)“返回頂部”的按鈕,用戶點(diǎn)擊一下,就可以回到頂部,對(duì)于用戶來(lái)說(shuō),是一個(gè)比較好的體驗(yàn)。
    2015-05-05
  • 淺談javascript獲取元素transform參數(shù)

    淺談javascript獲取元素transform參數(shù)

    本文主要給大家簡(jiǎn)單介紹了javascript獲取元素的transform參數(shù)的方法以及個(gè)人的理解,記錄下來(lái)分享給大家。
    2015-07-07

最新評(píng)論