我正在使用一个名为beforeAfter的插件(http://www.catchmyfame.com/2009/06/25/jquery-beforeafter-plugin/),并且这种方式已经实现了它,我想只用公司点击甚至在用户使用屏幕时说580px。现在我有它的开发代码,但不确定如何添加媒体查询。jQuery媒体查询
下面是完整的代码 http://jsbin.com/ojuwid/1/
链接这里是在插件文件中的片断,我需要将其纳入媒体查询:
// When clicking in the container, move the bar and imageholder divs
$(obj).click(function(e){
var clickX = e.pageX - $(this).offset().left;
$('#dragwrapper'+randID).stop().animate({'left':clickX-($('#dragwrapper'+randID).width()/2)+'px'},o.clickSpeed);
$('div:eq(2)', obj).stop().animate({'width':clickX+'px'},o.clickSpeed);
$('#lt-arrow'+randID+',#rt-arrow'+randID).stop().animate({opacity:0},50);
});
$(obj).one('mousemove', function(){$('#dragwrapper'+randID).stop().animate({'opacity':1},500);});
// If the mouse is over the container and we animate the intro, we run this to change the opacity when the mouse moves since the hover event doesnt get triggered yet
}
});
如果任何人有任何想法或方法他们如何做到这一点将会很棒! PS-I知道媒体查询是一个CSS概念 - 只是不确定如何触发窗口调整大小查询到这个插件。
你可以只添加一个条件,如“if($(window).width()<= 580)'? –
这只会进入插件脚本本身?为此事道歉! – user2212564
请参阅以上以及完整代码 –