Giter Club home page Giter Club logo

inputfocus's Introduction

-----------/样式需要自定义,以下参考/-----------------------

{margin:0;padding:0;} input{ padding: 0 0 0 10px; height: 38px; line-height: 38px; border: solid 1px #f1f1f1; vertical-align: middle; width:222px; } /-----foucus inoput----------*/ .focusinput-wrap{ position:absolute; background: #fff none repeat scroll 0 0; border: 1px solid #ccc; width: 222px; } .focusinput-wrap .focusinput-inner{

}

.focusinput-wrap .focusinput-list{ max-height: 300px; overflow-x: hidden; overflow-y: auto; position: relative; width: 222px; padding: 0; }

.focusinput-wrap .focusinput-list li{ display: block; width: 100%; height: 30px; line-height: 30px; float: none; overflow: hidden; } .focusinput-wrap .focusinput-list li a{ background: #fff none repeat scroll 0 0; color: #666; display: block; padding-left: 10px; }


//依赖jquery1.6以上 $(function () { /* //调用方式一: 输入固定内容 数组 过滤显示相关内容 $('input').inputFocus({ source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ] }); */

//调用方式二: 输入固定内容, 过滤 开头相关内容 var tags = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ]; $('#name1').inputFocus({ source: function( request, response ) { var matcher = new RegExp( "^" + this._escapeRegex( request.term ), "i" ); response( $.grep( tags, function( item ){ return matcher.test( item ); }) ); } });

/* //调用方式三: 传入 服务路径, 动态请求api 读库显示相关内容 $('#name1').inputFocus({ source:'http://jiancai.jiaju.sina.com.cn/index.php?app=Api2015&mod=Brand&act=get_auto_brand', dataType:'jsonp', targetDom:'#name', normalizeFun: function (ret) { // array // for Example // [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ] // [{lable:'label1', value:'value1'}, {lable:'label2', value:'value2'}] var a = []; if (ret && ret.status == 1 && ret.data) { var data = ret.data; if (data && data.length > 0){ return $.map( data, function( item ) { return { label: item.name, value: item.id }; }); } a = data; } return a; }, searchFun: function (val) { this.source( { q: val }, this._response() ); }

    });

*/

});



inputfocus's People

Contributors

cantianshu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.