web前端|js教程
javascript,select
web前端-js教程
最近迷茫于javascript的闭包与继承,写一个小东西找找感觉。
三端平台源码,ubuntu如何手动升级,爬虫英文水平,兴趣部落php,seo韩国明星lzw
JS+CSS模拟Select下拉框,选择表单效果
360建站系统源码,投屏软件 ubuntu,2个tomcat改端口,python爬虫后台,php代码在哪里运行,庐江seolzw
网页中使用Select语法实现的下拉框是很普遍的,但是您有没有见过使用JS+CSS模拟的Select下拉框?并且可以选择表单哦,尽管代码复杂了点,但是对于我们了解此类特效非常有帮助。
j2ee应用开发源码,vscode 隐藏缩略图,ubuntu无效主题,tomcat默认部署配置,爬虫任务图谱,php变长参数,全网seo推广有用吗,小说合作网站源,微赞如何安装pc模板lzw
测试一 测试二 测试三 测试四 测试五 测试六
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]这个作品在没有任何需求下完成,不保证能应用于实际应用,仅用于自娱自乐。
浏览器默认样式
select1select2select3select4
js模拟select,样式主要参照IE8与Firefox。
select1
select2
select3
select4
在不改变HTML结构的前提下,可更改其它样式。建议用IE8与FF浏览,可与默认样式进行对比。
// <![CDATA[ function beginSelect(elem){ if(elem.className == "btn"){ elem.className = "btn btnhover" elem.onmouseup = function(){ this.className = "btn" } } var ul = elem.parentNode.parentNode; var li = ul.getElementsByTagName("li"); var selectArea = li[li.length-1]; if(selectArea.style.display == "block"){ selectArea.style.display = "none"; } else{ selectArea.style.display = "block"; mouseoverBg(selectArea); } } function mouseoverBg(elem1){ var input = elem1.parentNode.getElementsByTagName("input")[0]; var p = elem1.getElementsByTagName("p"); var pLength = p.length; for(var i = 0; i < pLength; i++){ p[i].onmouseover = showBg; p[i].onmouseout = showBg; p[i].onclick = postText; } function showBg(){ this.className == "hover"?this.className = " ":this.className = "hover"; } function postText(){ var selected = this.innerHTML; input.setAttribute("value",selected); elem1.style.display = "none"; } } // ]]>
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]用js模拟实现表单select选择的功能
/* s_search start */ var sortname; var age; var addr; var keywords; var dropShow=false; var currentID; function dropdown(el){ if(dropShow){ dropFadeOut(); }else{ currentID=document.getElementById(el); currentID.style.visibility=”visible”; dropFadeIn(); } } function dropFadeIn(){//选单淡入的效果 if(currentID.filters.alpha.opacity0){ clearTimeout(fadeTimer); currentID.filters.alpha.opacity-=20; fadeTimer=setTimeout(“dropFadeOut()”,50); }else{ dropShow=false; currentID.style.visibility=”hidden”; } } function dropdownHide(){ if(dropShow){ dropFadeOut(); dropShow=false; } } function hiLight(el){//高亮度显示指标位置 if(dropShow){ for(i=0;i= 0){tempTxt=el.innerText.replace(“┝”,””);} document.getElementById(“text”).innerText=tempTxt.substring(0,tempTxt.indexOf(“|”)); tempstr=tempTxt.substring(tempTxt.indexOf(“|”)+1); } function CheckMe1(el){//替换显示内容 document.getElementById(“text1”).innerText=el.innerText; sortname=el.innerText; } function CheckMe2(el){//替换显示内容 document.getElementById(“text2”).innerText=el.innerText; age=el.innerText; } function CheckMe3(el){//替换显示内容 document.getElementById(“text3”).innerText=el.innerText; addr=el.innerText; } document.onclick=dropdownHide; function go_search(){ keywords=document.getElementById(“form_search”).keywords.value; if(!sortname){sortname=””;} if(!age){age=””;} if(!addr){addr=””;} if(keywords==”请输入你要找的信息!”){keywords=””;} location.href=”userlist.php?sortname=”+sortname+”&age=”+age+”&addr=”+addr+”&keywords=”+keywords; } /* s_search end */
类别1
类别2
类别3
18-25岁
26-32岁
上海
浙江
福建
广东
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]在不改变HTML结构的前提下,可更改其它样式。建议用IE8与FF浏览,可与默认样式进行对比。
发布一来是为了记录自己学习过程,二来想请朋友指点一下迷津,哪些地方欠妥或者有更好的思路可以给我指点一下,谢谢。