$(function () {
var menu = $('#menu'),
active = $('a', menu).filter('[href*="' + location.href + '"]');
$('ul', menu).hide();
menu.on('click', 'span', show);
if (active.length) {
show.call(active.closest('ul').get(0));
}
function show () {
$(this).next().slideToggle('normal');
}
});
var cell = [];
function loop (o){
Object.keys(o).forEach(function (innerObject) {
Object.keys(o[innerObject]).forEach(function (prop) {
console.log(
'Property: ' + prop,
'Value: ' + o[innerObject][prop],
'in Inner Object: ' + innerObject
);
});
});
};
var myMap = new ymaps.Map('map', {
center: [55.74954, 37.621587],
zoom: 10,
controls: []
});
(function () {
try {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
for (var i = mutation.addedNodes.length; i--;) {
addedControl(mutation.addedNodes[i]);
}
});
});
document.addEventListener('DOMContentLoaded', function (e) {
observer.observe(document.body, {
childList: true
});
}, false);
} catch (z) {
document.addEventListener('DOMNodeInserted', function (e) {
addedControl(e.target);
}, false);
}
function addedControl (target) {
console.log(target);
}
})();
document.addEventListener('click', function (e) {
if (e.target.tagName == 'BUTTON') {
document.body.appendChild(document.createElement('iframe'));
}
}, false);
<button type="button">Добавить</button>
var date = {
year: 2014,
month: 7,
date: 13
};
document.write(
Date.UTC(
date.year,
date.month || 0,
date.date || 1
)
);
$.ajax({
url: '...'
}).done(function (data) {
var count;
$('.target').append(data).find('img').each(function () {
if (this.readyState != 'complete') {
count++;
$(this).on('load', checkCount);
}
});
function checkCount () {
count--;
if (count == 0) {
// Вперёд, к звёздам
}
}
}).fail(function () {
// Про ошибки помним
});
someField.value = someField.defaultValue;