您将如何添加具有特定颜色的可拖动对象,例如蓝色?
我一直在用
<script type="text/javascript">
$( function() {
$( ".box" ).draggable({containment: "parent"});
$( ".box" ).css("background-color","blue");
});
</script>
但它没有显示颜色变化,因为它保持白色。另外,为什么会这样?
最佳答案
var color = function(color){
//processing here
return color;
}
$( function() {
$( ".box" ).draggable({containment: "parent"});
$( ".box" ).css("background-color",color("whatever"));
});
您可以在颜色函数中添加某种类型的逻辑,以根据需要更改颜色
关于javascript - 为可拖动对象添加颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25538191/