/ Published in: JavaScript
URL: http://dealis.pl/bzdury/js-multi-range/
Look at demo.
Expand |
Embed | Plain Text
$(function(){ $.e.range = function(a1,a2,a3){ var a1=$(a1), p1=this.positionFromEdge(), p2=a1.positionFromEdge(), r=[]; for(var y=0,T=this,Y=T.length;y<Y;y++){ for(var z=0,Z=a1.length;z<Z;z++){ var AI = { x:a1[z].offsetWidth+a1[z].offsetLeft, y:a1[z].offsetHeight+a1[z].offsetTop }; var TI = { end:{ x:T[y].offsetWidth+T[y].offsetLeft, y:T[y].offsetHeight+T[y].offsetTop }, start : { x:T[y].offsetLeft, y:T[y].offsetTop } }; if((a1[z].offsetLeft).range(TI.start.x, TI.end.x) && (a1[z].offsetTop).range(TI.start.y, TI.end.y) || (AI.x).range(TI.start.x, TI.end.x) && (AI.y).range(TI.start.y, TI.end.y)){ $.func(a2).call(this, a1[z]); } else { $.func(a3).call(this, a1[z]); } } } return this; }; // ========= Example $(".b1").range(".b2, .b3, .b4", function(a1){ $(a1).css("background-color:green;"); }, function(a1){ $(a1).css("background-color:red;"); }); });
You need to login to post a comment.
