Home  >  Article  >  Web Front-end  >  Imitation select function code implemented by jQuery_jquery

Imitation select function code implemented by jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 15:44:121378browse

The example in this article describes the imitation select function implemented by jQuery. Share it with everyone for your reference. The details are as follows:

Here I would like to share with you the jQuery imitation select function again. This is not complicated to implement. Just study the usage of the jQuey plug-in. I hope you like it.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/jquery-fselect-cha-method-codes/

The specific code is as follows:

<!dooCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta charset=utf-8>
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery.select.js" type="text/javascript"></script>
<title>jQuery select</title>
</head>
<style>
.select-my ul,.select-my li{
 margin:0;padding:0;
}
.select-my{
 position:absolute;
 min-width:100px;
 *width:100px;
 left:100px;
 top:20px;
 border:1px solid #aaa;
 border-bottom:none;
} 
.select-my b{
 float:left;
} 
.select-my span{
 float:right;
}
.select-my li{
 width:100%;
 min-height:20px;
 *height:20px;
 border-bottom:1px solid #aaa;
 line-height:20px;
 vertical-align:middle;
}
.select-my img{
 line-height:20px;
 vertical-align:middle; 
}
.select-my .select-my-list{
 border-bottom:none;
}
.select-my .select-my-list{
 display:none;clear:both;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
 $('#select-1').makeSelect({
  className:'my',
   dataValue:[1,2,3],
   dataHtml:['1','二','3'],
   callback:function(){
   $('#msg').val( $('#select-1').val() );//显示选中的值
   }
 });
 $('#select2').makeSelect({
  description:'请',
  logo:['▽','△'],
  className:'',
   dataValue:[1,2,3],
   dataHtml:['<img src=images/a1.jpg width=20 height=20 />1','<img src=images/a2.jpg width=20 height=20 />二','<img src=images/a3.jpg width=20 height=20 />33ssssssssssaaa'],
   callback:function(){
   $('#msg').val( $('#select2').val() );//显示选中的值
   }
 });
});
</script>
<body>
<div class="select" id="select-1"></div>
<div id="select2" style="position:absolute;top:200px;left:200px;">select2</div> 
<div style="position:absolute;left:300px;top:330px;">被选中的值是<input type="text" id="msg"/></div>
</body>
</html>

I hope this article will be helpful to everyone’s jquery programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn