1
0
mirror of synced 2024-11-22 21:16:10 +03:00
select2/select2-test.html

58 lines
1.9 KiB
HTML
Raw Normal View History

2013-02-06 03:24:44 +04:00
<html>
<head>
<script src="js/jquery-1.8.1.js"></script>
<script src="select2-master/select2.js"></script>
<link href="select2-master/select2.css" rel="stylesheet"/>
<style>img.flag { height: 10px; width: 15px; padding-right: 10px; }
</style>
</head>
<body>
<div style="padding: 10px; margin: 10px;">
2013-02-09 00:13:59 +04:00
<br/><br/><br/>
<input type="text" size="30"/><br/>
2013-02-06 03:24:44 +04:00
<select id="e4" style="width:300px" class="populate">
2013-02-09 00:13:59 +04:00
<option></option>
2013-02-06 03:24:44 +04:00
<option value="AK">Alaska</option>
<option value="HI">Hawaii</option>
<option value="CA">California</option>
<option value="NV">Nevada</option>
<option value="OR">Oregon</option>
<option value="WA">Washington</option>
</select><br/>
2013-02-09 00:13:59 +04:00
<input type="text" size="30"/>
2013-02-06 03:24:44 +04:00
</div>
<script>
$(document).ready(function() {
function format(state) {
if (!state.id) return state.text; // optgroup
return "<img class='flag' src='images/flags/" + state.id.toLowerCase() + ".png'/>" + state.text;
}
$("#e4").select2({
formatResult: format,
2013-02-09 00:13:59 +04:00
formatSelection: format,
escapeMarkup: function(m) { return m; },
allowClear:true,
placeholder: "select a state"
2013-02-06 03:24:44 +04:00
});
});
</script>
2013-02-09 00:13:59 +04:00
<div style="position: absolute; left:0; top:0; background: white; border: 1px solid red;" id="focus-spy">hello there</div>
<script>
$(document).ready(function() {
var el=$("#focus-spy");
$(window).bind("scroll", function(){ el.css({top:$(window).scrollTop()}); });
var update=function() {
var a=document.activeElement;
var b=$(a);
el.html("tag: "+a.tagName+" id:"+a.id+" class:"+b.attr("class")+" val:"+b.val());
window.setTimeout(update, 100);
};
update();
});
</script>
2013-02-06 03:24:44 +04:00
</body>
</html>