我同时加载了jQuery和MooTools,但mooTools添加了更多元素,我可以找出原因。当我删除mootools它完美的工作。不幸的是,我需要mootools用于其他不相关的脚本。
beforeImg.addClass("halfhalf-before");
afterImg.addClass("halfhalf-after");
container.append("<div class='halfhalf-shandle'></div>");
var halfslider = container.find(".halfhalf-shandle");
// append additional html element
var overlay = container.find(".halfhalf-overlay");
overlay.append("<div class='halfhalf-before-label'></div>");
overlay.append("<div class='halfhalf-after-label'></div>");
//adjustContainer
var aContainer = function(offset) {
beforeImg.css("clip", "rect(0,"+offset.cw+","+offset.h+",0)");
container.css("height", offset.h);
$('#debug5').html("offsetWidth: " + +offset.cw+","+offset.h+",0)");
};
var adjustSlider = function(pct) {
var offset = calcOffset(pct);
halfslider.css({left: offset.cw, top: '50%'}); //When I moved the slider top and absolute gets over written
$('#debug6').html("left: " +offset.cw); // nothing changes in the debug.
aContainer(offset);
}