在jQuery UI可选演示页面上:http://jqueryui.com/demos/selectable/#default选择元素时,可以看到选择框大纲。为什么当我尝试时它不会出现?
这不是我的小提琴,但它也有同样的问题: http://jsfiddle.net/jMDVm/40/
答案 0 :(得分:7)
这是因为它缺少jQuery UI样式表,其中包含用于为选择助手框设置样式的类。将以下内容添加到CSS中:
.ui-selectable-helper {
position: absolute;
z-index: 100;
border: 1px dotted black;
}
$(document).ready(function() {
$("#selectable").selectable({
selected: function(event, ui) {
$('.status').text("Selected");
},
selecting: function(event, ui) {
$('.status').text("Selecting");
}
});
});
#wrapper {
width: 250px;
height: 100px;
}
#selectable {
background: black;
width: 250px;
height: 16px;
}
#selectable .ui-selecting {
background: silver;
}
#selectable .ui-selected {
background: gray;
}
#selectable div {
background-color: #777;
}
.ui-selectable-helper {
position: absolute;
z-index: 100;
border: 1px dotted black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js"></script>
<div id="wrapper">
<div id="selectable">
<div>Hello</div>
<div>Select</div>
<div>Me</div>
</div>
</div>
<div class="status"></div>