
本文共 706 字,大约阅读时间需要 2 分钟。
我有一个解决方案,选择上方显示的范围,直到完成选择。跨度显示默认的消息,所以它不是在命题的列表:
HTML:
Default message
Option 1
Option 2
Option 3
CSS:
#default_message_overlay {
position: absolute;
display: block;
width: 120px;
color: grey;
}
select {
width: 150px;
}
的JavaScript(用jQuery):
$(document).ready(function() {
// No selection at start
$('#my_select').prop("selectedIndex", -1);
// Set the position of the overlay
var offset = $('#my_select').offset();
offset.top += 3;
offset.left += 3;
$('#default_message_overlay').offset(offset);
// Remove the overlay when selection changes
$('#my_select').change(function() {
if ($(this).prop("selectedIndex") != -1) {
$('#default_message_overlay').hide();
}
});
});
我制作了jsfiddle for demo。经过Firefox和IE8测试。
转载地址:https://blog.csdn.net/weixin_33958381/article/details/117757796 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关于作者
