How to write a function for jQuery that adds an ondrag event to all elements of a set? The definition of the function was written, and the crawl on the elements I do not know how to implement ..

    2 answers 2

    $(function(){ var elements = $(".some-class"); //Берем элементы elements.each(function(){ //Пробегаим их по очереди this.bind("ondrag", function(){...}); //Добавляем каждому обработчик }); }); 
    • Unfortunately .bind doesn't add DOM events - Biohazard
     (function (b) { b.fn.MyFn = function () { return this.each(function () { //элемент: b(this) //ваш код }); }; })(jQuery);