var list = $('[data-image]');
$(document).on('click', '[data-image]', function (e) {
list.index($(this)); //это — индекс элемента в найденной ранее коллекции
});
$(function () {
var list = $('[data-image]');
list.on('click', function (e) {
var current = $(this), //элемент коллекции, на котором произошёл клик
next = list.eq(list.index(current) + 1); //а вот и он — следующий элемент коллекции
});
});
$(document).on('click', '.butt', function () {
console.log($(this)); // это и есть наш элемент с классом butt
});
$(document).on('click', '[data-dialog]', function (e) {
e.preventDefault();
});
$(function () {
var trigger = $('[data-dialog]'),
type = trigger.data('dialog'),
dialog = new DialogFx(type);
trigger.on('click', function (e) {
e.preventDefault();
dialog.toggle.bind(dialog);
});
})();
var myObject = {
prop1: function () {
console.log('Анимация прошла!');
},
prop2: function () {
$('div').animate({
opacity: 0.25
}, 100, function () {
this.prop1();
}.bind(this));
}
}
myObject.prop2();
var myObject = function () {
/*А тут можно много чего приватного создать*/
var _class = {
prop1: function () {
console.log('Анимация прошла!');
},
prop2: function () {
$('div').animate({
opacity: 0.25
}, 100, function () {
_class.prop1();
});
}
};
return _class;
}();
myObject.prop2();
var iframe = document.createElement('iframe');
window.addEventListener('message', function (e) {
iframe.height = e.data;
});
iframe.src = '...';
iframe.scrolling = 'no';
iframe.width = 300;
iframe.height = 300;
document.body.appendChild(iframe);
window.addEventListener('load', function () {
parent.postMessage(document.documentElement.scrollHeight, '*');
});
var x = set(42);
console.log(x);
function set (max_number) {
var array = [];
set.unic = [];
while (array.length < max_number) {
array.push(get());
}
delete set.unic;
return array;
function get (a) {
do {
a = Math.floor(Math.random() * max_number);
} while (isFinite(set.unic[a]));
return a;
}
}