Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Support for touch devices Reply To: Support for touch devices

#181583
Soronbe
Participant
function setRandomPos(elements,x,dx){
    elements.each(function(){
        fixLeft=(Math.floor(Math.random()*x)*10) + dx;
        fixTop = (Math.floor(Math.random()*30)*10) + 170;
        $(this).offset({
            left: fixLeft,
            top: fixTop
        });     
    });
}

Should be your entire setRandomPos.js file. Then do call setRandomPos($(".panels"),80,40);. I did not make the function extend the jQuery object, but if you want me to I can.
This would allow $(".panels").setRandomPos(80,40).