}
if( classes !== ” ) {
optclass = ‘class=”‘ + classes + ‘” ‘;
}
return ‘<li ‘ + optclass + link + ‘ data-option data-value=https://www.520longzhigu.com/diannao/”‘ + el.value + ‘”>’ + el.textContent + ‘’;
};
[].slice.call( this.el.children ).forEach( function(el) {
if( el.disabled ) { return; }
var tag = el.tagName.toLowerCase();
if( tag === ‘option’ ) {
options += createOptionHTML(el);
}
else if( tag === ‘optgroup’ ) {
options += ‘<li class=”cs-optgroup”><span>’ + el.label + ‘</span><ul>’;
[].slice.call( el.children ).forEach( function(opt) {
options += createOptionHTML(opt);
} )
options += ‘</ul></li>’;
}
} );
var opts_el = ‘<div class=”cs-options”><ul>’ + options + ‘</ul></div>’;
this.selEl = document.createElement( ‘div’ );
this.selEl.className = this.el.className;
this.selEl.tabIndex = this.el.tabIndex;
this.selEl.innerHTML = ‘<span class=”cs-placeholder”>’ + this.selectedOpt.textContent + ‘</span>’ + opts_el;
this.el.parentNode.appendChild( this.selEl );
this.selEl.appendChild( this.el );
}
/**
* initialize the events
*/
SelectFx.prototype._initEvents = function() {
var self = this;
// open/close select
this.selPlaceholder.addEventListener( ‘click’, function() {
self._toggleSelect();
} );
// clicking the options
this.selOpts.forEach( function(opt, idx) {
opt.addEventListener( ‘click’, function() {
self.current = idx;
self._changeOption();
// close select elem
self._toggleSelect();
} );
} );
// close the select element if the target it′s not the select element or one of its descendants..
document.addEventListener( ‘click’, function(ev) {
var target = ev.target;
if( self._isOpen() && target !== self.selEl && !hasParent( target, self.selEl ) ) {
self._toggleSelect();
}
} );
// keyboard navigation events
this.selEl.addEventListener( ‘keydown’, function( ev ) {
var keyCode = ev.keyCode || ev.which;
switch (keyCode) {
// up key
case 38:
ev.preventDefault();
self._navigateOpts(‘prev’);
break;
// down key
case 40:
ev.preventDefault();
self._navigateOpts(‘next’);
break;
// space key
case 32:
ev.preventDefault();
if( self._isOpen() && typeof self.preSelCurrent != ‘undefined’ && self.preSelCurrent !== -1 ) {
self._changeOption();
}
self._toggleSelect();
break;
// enter key
case 13:
ev.preventDefault();
if( self._isOpen() && typeof self.preSelCurrent != ‘undefined’ && self.preSelCurrent !== -1 ) {
self._changeOption();
self._toggleSelect();
}
break;
// esc key
case 27:
ev.preventDefault();
if( self._isOpen() ) {
self._toggleSelect();
}
break;
}
} );
}
/**
* navigate with up/dpwn keys
*/
SelectFx.prototype._navigateOpts = function(dir) {
if( !this._isOpen() ) {
this._toggleSelect();
}
var tmpcurrent = typeof this.preSelCurrent != ‘undefined’ && this.preSelCurrent !== -1 ? this.preSelCurrent : this.current;
if( dir === ‘prev’ && tmpcurrent > 0 || dir === ‘next’ && tmpcurrent < this.selOptsCount – 1 ) {
以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!
「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助:- 教你制作百分比柱形图 excel怎么画柱状图怎么标数据
- excel一键去除公式 excel删除公式保留数据公式
- 附学习路线图 java学习体系框架
- 设置按钮无边框的方法 js复选框是否选中
- 误删的excel表格恢复方法 excel工作表误删后找回老版本
- excel表格向下三角箭头 excel箭头怎么输入
- 电脑输入法不显示选字框 电脑输入法怎么删除
- excel转换成pdf文件方法 excel转pdf分页了怎么办
- 表格分列怎么用 excel分列怎么用
- 强制换行和自动换行 excel表格里换行按什么键