ここでの問題は、toggleClassの位置のトップです。0px;左:0pxはトリガされません..幅と高さと背景色のみがアクティブになります.. div(ドラッグ可能)をドラッグしないとうまくいきます。もし要素をドラッグし始めると、効果..私はjQuery draggable + toggleClassの問題
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery.ui.widget.js"></script>
<script type="text/javascript" src="jquery.ui.mouse.js"></script>
<script type="text/javascript" src="jquery.ui.resizable.js"></script>
<script type="text/javascript" src="jquery.ui.draggable.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#x").draggable().dblclick(function(){
$(this).toggleClass("hi");
});
});
</script>
<style>
.hello {
background:red;
width:200px;
height:200px;
position:relative;
top:100px;
left:100px;
}
.hi {
background:yellow;
position:relative;
width:300px;
height:300px;
top:0px;
left:0px;
}
</style>
</head>
<body>
<div id="x" class="hello">
</div>
</body>
</html>
私の問題を解決する..ありがとうございました。:D –