邮箱下拉自动填充选择示例代码附图_javascript技巧_脚本之家

2019-12-01 12:47栏目:竞技宝竞猜
TAG:

1.亟待一个js文件:jquery.mailAutoComplete-3.1.js 复制代码 代码如下: { $.fn.mailAutoComplete = function{ var defaults = { boxClass: "mailListBox", //外界box样式 listClass: "mailListDefault", //默许的列表样式 focusClass: "mailListFocus", //列表选样式中 markCalss: "mailListHlignt", //高亮样式 zIndex: 1, autoClass: true, //是还是不是选拔插件自带class样式 mailArr: ["qq.com","gmail.com","126.com","163.com","hotmail.com","yahoo.com","yahoo.com.cn","live.com","sohu.com","sina.com"], //邮件数组 textHint: false, //文字提醒的全自动展现与掩盖 hintText: "", focusColor: "#333", blurColor: "#999" }; var settings = $.extend({}, defaults, options || {}卡塔尔(قطر‎; //页面装载CSS样式 if(settings.autoClass && $.size{ $('

[javascript] 
加多CSS的艺术有行内式、嵌入式、外链式、导入式 
a卡塔尔(英语:State of Qatar)动态引进样式表文件: 
function loadLink(url){ 
    var link = document.createElement("link"); 
    link.type = "text/css"; 
    link.rel  = "stylesheet"; 
    link.href  = url; 
    var head = document.getElmentsByTagName("head")[0]; 
    head.appendChild(link); 

b)嵌入式: 
function insertStyles(){ 
    var doc,cssCode=[],cssText; 
    var len = arguments.length; 
    var head,style,firstStyle; 
    if(len == 1){ 
        doc = document; 
        cssCode.push(arguments[0]) 
    }else if(len == 2){ 
        doc = arguments[0]; 
        cssCode.push(arguments[1]); 
    }else{ 
        alert("函数最多抽取五个参数!"卡塔尔国; 
    } 
    head = doc.getElementsByTagName("head")[0]; 
    styles= head.getElementsByTagName("style"); 
    if(styles.length == 0){ 
        if(doc.createStyleSheet){//ie  
            doc.createStyleSheet(); 
        }else{//FF  
            var tempStyle = doc.createElement("style"); 
            tempStyle.setAttibute("type","text/css"); 
            head.appendChild(tempStyle); 
        } 
    } 
    firstStyle = styles[0]; 
    cssText=cssCode.join("n"); 
    if(!+"v1"){//opacity兼容  
        var str = cssText.match(/opacity:(d?.d+);/);  
        if(str!=null){ 
            cssText = cssText.replace(str[0],"filter:alpha(opacity="+pareFloat(str[1])*100+")"); 
        } 
    } 
    if(firstStyle.styleSheet){ 
        firstStyle.styleSheee.cssText += cssText; 
    }else if(doc.getBoxObjectFor){ 
        firstStyle.innerHTML += cssText; 
    }else{ 
        firstStyle.appendChild(doc.createTextNode(cssText)); 
    } 

c)行内式: 
var addStyle=function (ele,str){ 
    var s = ele.getAttribute("style"),styles; 
    if(str && typeof str === "string"){ 
        if(!s){ 
            ele.style.cssText = str; 
        }else{ 
            if(s == '[object]'){//IE6/7 e.getAttribute("style")返回[object]  
                s=ele.style.cssText; 
            } 
            styles= trim(s).split(";"); 
            for (var i=0,len=styles.length; i<len; i++){ 
                var style_i=trim(styles[i]); 
                var attr=style_i.split(":")[0]; 
                if(str.indexOf(attr)>-1){ 
                    styles[i]=""; 
                }else{ 
                    styles[i]=style_i; 
                } 
            } 
            ele.style.cssText= styles.join("")+";"+str; 
        } 
    } 

d)导入式: 
import "index.css"; 
 
操作CSS 类相关的章程: 
var hasClass=function(ele,value){ 
    var rclass = /[ntr]/g, 
        value=" "+value+" "; 
    return (ele.nodeType==1)&&(" "+ele.className+" ").replace(rclass," ").indexOf(value)>-1; 

var trim=function (val){ 
    return val.replace(/(^s+)|(s+$)/g,""); 

var addClass=function(ele,value){ 
    var rspace = /s+/,classNames,getClass; 
    if(value&&typeof value === "string"){ 
        classNames = value.split(rspace); 
        if(ele.nodeType === 1){ 
            if(!ele.className && classNames.length == 1){ 
                ele.className = value; 
            }else{ 
                getClass = " "+ele.className+" "; 
                for(var i=0,len=classNames.length; i<len ;i++){ 
                    var cname=classNames[i]; 
                    if(!hasClass(ele,cname)){ 
                        getClass += cname+" "; 
                    } 
                } 
                ele.className = trim(getClass); 
            } 
        } 
    } 

 
var removeClass=function(ele,value){ 
    var rclass = /[ntr]/g,classNames,getClass; 
    if((value&&typeof value === "string")||value === undefined){ 
        classNames = (value||"").split(rspace); 
        if(ele.nodeType === 1 && ele.className){ 
            if(value卡塔尔{//存在查找要移除的类  
                getClass =  " "+ele.className+" ".replace(rclass," "卡塔尔国;//左右空格,为了使类中各队间均等,方便前面替换  
                for(var i=0,len=classNames.length; i<len; i++){ 
                    getClass = getClass.replace(" "+classNames[i]+" "," ") 
                } 
                ele.className=trim(getClass); 
            }else{//一纸空文移除全体类  
                ele.className = ""; 
            } 
        } 
    } 

var toggleClass=function(ele,value){ 
    if(typeof value === "string"){ 
        if(hasClass(ele,value)){ 
            removeClass(ele,value); 
        }else{ 
            addClass(ele,value); 
        } 
    } 

'卡塔尔(قطر‎.appendTo; } var cb = settings.boxClass, cl = settings.listClass, cf = settings.focusClass, cm = settings.markCalss; //插件的class变量 var z = settings.zIndex, newArr = mailArr = settings.mailArr, hint = settings.textHint, text = settings.hintText, fc = settings.focusColor, bc = settings.blurColor; //创造邮件内部列表内容 $.createHtml = function{ var mailHtml = ""; if{ $.each{ if{ mailHtml += '

增添CSS的不二等秘书籍有行内式、嵌入式、外链式、导入式
a卡塔尔(英语:State of Qatar)动态引进样式表文件:
function loadLink(url){
 var link = document.createElement("link");
 link.type = "text/css";
 link.rel  = "stylesheet";
 link.href  = url;
 var head = document.getElmentsByTagName("head")[0];
 head.appendChild(link);
}
b)嵌入式:
function insertStyles(){
 var doc,cssCode=[],cssText;
 var len = arguments.length;
 var head,style,firstStyle;
 if(len == 1){
  doc = document;
  cssCode.push(arguments[0])
 }else if(len == 2){
  doc = arguments[0];
  cssCode.push(arguments[1]);
 }else{
  alert("函数最多抽取七个参数!"卡塔尔;
 }
 head = doc.getElementsByTagName("head")[0];
 styles= head.getElementsByTagName("style");
 if(styles.length == 0){
  if(doc.createStyleSheet){//ie
   doc.createStyleSheet();
  }else{//FF
   var tempStyle = doc.createElement("style");
   tempStyle.setAttibute("type","text/css");
   head.appendChild(tempStyle);
  }
 }
 firstStyle = styles[0];
 cssText=cssCode.join("n");
 if(!+"v1"){//opacity兼容
  var str = cssText.match(/opacity:(d?.d+);/);
  if(str!=null){
   cssText = cssText.replace(str[0],"filter:alpha(opacity="+pareFloat(str[1])*100+")");
  }
 }
 if(firstStyle.styleSheet){
  firstStyle.styleSheee.cssText += cssText;
 }else if(doc.getBoxObjectFor){
  firstStyle.innerHTML += cssText;
 }else{
  firstStyle.appendChild(doc.createTextNode(cssText));
 }
}
c)行内式:
var addStyle=function (ele,str){
 var s = ele.getAttribute("style"),styles;
 if(str && typeof str === "string"){
  if(!s){
   ele.style.cssText = str;
  }else{
   if(s == '[object]'){//IE6/7 e.getAttribute("style")返回[object]
    s=ele.style.cssText;
   }
   styles= trim(s).split(";");
   for (var i=0,len=styles.length; i<len; i++){
    var style_i=trim(styles[i]);
    var attr=style_i.split(":")[0];
    if(str.indexOf(attr)>-1){
     styles[i]="";
    }else{
     styles[i]=style_i;
    }
   }
   ele.style.cssText= styles.join("")+";"+str;
  }
 }
}
d)导入式:
import "index.css";

'+str+'@'+arr[i]+'

操作CSS 类相关的措施:
var hasClass=function(ele,value){
 var rclass = /[ntr]/g,
  value=" "+value+" ";
 return (ele.nodeType==1)&&(" "+ele.className+" ").replace(rclass," ").indexOf(value)>-1;
}
var trim=function (val){
 return val.replace(/(^s+)|(s+$)/g,"");
}
var addClass=function(ele,value){
 var rspace = /s+/,classNames,getClass;
 if(value&&typeof value === "string"){
  classNames = value.split(rspace);
  if(ele.nodeType === 1){
   if(!ele.className && classNames.length == 1){
    ele.className = value;
   }else{
    getClass = " "+ele.className+" ";
    for(var i=0,len=classNames.length; i<len ;i++){
     var cname=classNames[i];
     if(!hasClass(ele,cname)){
      getClass += cname+" ";
     }
    }
    ele.className = trim(getClass);
   }
  }
 }
}

'; }else{ mailHtml += '

var removeClass=function(ele,value){
 var rclass = /[ntr]/g,classNames,getClass;
 if((value&&typeof value === "string")||value === undefined){
  classNames = (value||"").split(rspace);
  if(ele.nodeType === 1 && ele.className){
   if(value卡塔尔(英语:State of Qatar){//存在查找要移除的类
    getClass =  " "+ele.className+" ".replace(rclass," "卡塔尔(英语:State of Qatar);//左右空格,为了使类中各队间均等,方便后边替换
    for(var i=0,len=classNames.length; i<len; i++){
     getClass = getClass.replace(" "+classNames[i]+" "," ")
    }
    ele.className=trim(getClass);
   }else{//一纸空文移除全体类
    ele.className = "";
   }
  }
 }
}
var toggleClass=function(ele,value){
 if(typeof value === "string"){
  if(hasClass(ele,value)){
   removeClass(ele,value);
  }else{
   addClass(ele,value);
  }
 }
}

'+str+'@'+arr[i]+'

 

版权声明:本文由龙竞技官网发布于竞技宝竞猜,转载请注明出处:邮箱下拉自动填充选择示例代码附图_javascript技巧_脚本之家