html下拉选中状态,前端必备 八种select下拉选择特效源码

a4c26d1e5885305701be709a3d33442f.png

效果图

各位朋友大家早上好!

今天给大家带来的是 八种select下拉选择特效源码!

在日常工作中会经常遇到!

大家可以按照自己的意愿,做成喜欢的样子!

需要文档版本源码,可以加我的HTML5前端交流群111645711

废话不多说,上源码!

;( function( window ) {

'use strict';

function hasParent( e, p ) {

if (!e) return false;

var el = e.target||e.srcElement||e||false;

while (el && el != p) {

el = el.parentNode||false;

}

return (el!==false);

};

function extend( a, b ) {

for( var key in b ) {

if( b.hasOwnProperty( key ) ) {

a[key] = b[key];

}

}

return a;

}

function SelectFx( el, options ) {

this.el = el;

this.options = extend( {}, this.options );

extend( this.options, options );

this._init();

}

SelectFx.prototype.options = {

// if true all the links will open in a new tab.

// if we want to be redirected when we click an option, we need to

define a data-link attr on the option of the native select

element

newTab : true,

// when opening the select element, the default placeholder (if

any) is shown

stickyPlaceholder : true,

// callback when changing the value

onChange : function( val ) { return false; }

}

SelectFx.prototype._init = function() {

// check if we are using a placeholder for the native select

box

// we assume the placeholder is disabled and selected by

default

var selectedOpt = this.el.querySelector( 'option[selected]' );

this.hasDefaultPlaceholder = selectedOpt &&

selectedOpt.disabled;

// get selected option (either the first option with attr selected

or just the first option)

this.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值