1
0
mirror of synced 2024-11-26 14:56:07 +03:00
select2/select2-test.html
2013-02-08 12:13:59 -08:00

58 lines
1.9 KiB
HTML

<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;">
<br/><br/><br/>
<input type="text" size="30"/><br/>
<select id="e4" style="width:300px" class="populate">
<option></option>
<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/>
<input type="text" size="30"/>
</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,
formatSelection: format,
escapeMarkup: function(m) { return m; },
allowClear:true,
placeholder: "select a state"
});
});
</script>
<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>
</body>
</html>