js中下拉菜单生成器dropMenu怎么用
                                            这篇文章主要介绍了js中下拉菜单生成器dropMenu怎么用,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

创新互联建站主要从事网站设计制作、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务任县,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792
HTML
职级:
js
$(function(){
 var title,
 populationType,
 titleInParty;
 $.ajax({
 url:'/api/v1/user/getUserTypeInfo',
 type:'GET',
 dataType:'json',
 success:function (data) {
  title=data.data.title;
  titleInParty=data.data.titleInParty;
  populationType=data.data.populationType;
  partyLabel('jobTitle',title);
  partyLabel('populationType',populationType);
  partyLabel('titleInParty',titleInParty);
 }
 });
function partyLabel(menuID,data){
 new DropMeun({
  'id':menuID,
  "data":data,
  "dataSrc":"name", //数据是下面的这种格式的,你要的是name的值
  "ableSearch":true, //可以搜索
  "style":{ //样式,可选
  "width":173,
  "maxHeight":200,
  "left":0, //定位到哪里
  "top":5,
  "initPos":"left" //设置在哪边出现
  }
 })
 }3.在页面中引用一个js 文件
(function(vq0599) {
 window.DropMeun = vq0599
})(function() {
 /*-- tools --*/
 function getRealTop(node) {
 return node.offsetParent.tagName.toUpperCase() === 'BODY' ?
 node.offsetTop :
 node.offsetTop + arguments.callee(node.offsetParent)
 }
 function getRealLeft(node) {
 return node.offsetParent.tagName.toUpperCase() === 'BODY' ?
 node.offsetLeft :
 node.offsetLeft + arguments.callee(node.offsetParent)
 }
 /*-- tools end--*/
 function DropMeun(option) {
  this.picker = null
  this.self = null
  this.option = option
  this.item = option.item || []
  this.style = option.style || {}
  this.dataList = option.data || []
  this.init()
 return this;
 }
 DropMeun.prototype.init = function () {
  var html = '',
    _this = this
  this.self = document.createElement('ul')
  this.picker = document.getElementById(this.option.id)
  if (! this.picker) {
   throw 'picker is null, making sure that picker\'s ID \''+ this.option.id +'\' is correct'
   return
  }
  if (this.option.ableSearch) {
   html += ''
  }
  this.dataList.forEach(function(data, index) {
   var item   = _this.option.dataSrc ? data[_this.option.dataSrc] : data,
     content = _this.item.render ? _this.item.render(item, data) : item
   html += '4.在页面中引用一个css文件
ul,
li {
 list-style: none;
 margin: 0;
 padding: 0;
}
.dropMeun {
 position: absolute;
 border: 1px solid #ccc;
 overflow: auto;
 padding: 8px 12px;
 box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
 background-color: #fff;
 border-bottom-left-radius: 4px;
 border-bottom-right-radius: 4px;
 box-sizing: content-box;
 display: none;
}
.dropMeun li.dropMeun-item {
 min-width: 150px;
 padding: 2px 2px;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}
.dropMeun li.dropMeun-item:hover {
 cursor: pointer;
 background-color: rgba(238, 238, 238, 0.8);
}
.dropMeun-searchInput {
 outline: none;
 width: 100%;
 box-sizing: border-box;
}感谢你能够认真阅读完这篇文章,希望小编分享的“js中下拉菜单生成器dropMenu怎么用”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!
本文题目:js中下拉菜单生成器dropMenu怎么用
标题来源:http://www.cqwzjz.cn/article/jcdjie.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 