/**
*下单框原生js插件
* dropdown作为元素class属性的属性值作用在需要添加下拉框效果的元素上
*example:
dropdown meonetwothree
四季
春
夏
秋
冬
<script src="dropdown.js"></script>
**/
var dropdowns = document.getElementsByClassName("dropdown");
Array.prototype.slice.call(dropdowns,0).forEach(function(item,index){
var dropdown = item;
var lis = Array.prototype.slice.call(dropdown.children,0);
lis.forEach(function(item,index){
item.setAttribute("style","display:none");
})
dropdown.firstElementChild.removeAttribute("style");
dropdown.onclick = function(){
lis.forEach(function(item,index){
var value = item.style.display;
if(value=="none"){
item.setAttribute("style","display:visibility");
}else{
item.setAttribute("style","display:none");
dropdown.firstElementChild.removeAttribute("style");
}
})
}
});