const parentSelector = 'div';
const childSelector = 'p';
const className = 'there';
const siblingsSelector = `${parentSelector} > ${childSelector}`;
const elementSelector = `${siblingsSelector}.${className}`;
const index = Array.prototype.findIndex.call(
document.querySelectorAll(siblingsSelector),
n => n.classList.contains(className)
);
let index = -1;
for (
let el = document.querySelector(elementSelector);
el;
index++, el = el.previousElementSibling
) ;
const el = document.querySelector(elementSelector);
const index = el ? [...el.parentNode.children].indexOf(el) : -1;
childSelector
, и они не должны учитываться, то третий вариант не подходит, а во втором надо заменить index++
на index += el.matches(childSelector)
. success: function() {
download(param1,param2,param3);
$('form').trigger('reset');
send_modal_form();
},
массив Array из объектов ArrayBuffer, ArrayBufferView, Blob, DOMString, или смесь любых из подобных объектов, которая может быть размещена внутри Blob. DOMStrings представлены в кодировке UTF-8.
type, with a default value of "", that represents the MIME type of the content of the array that will be put in the blob.
var marker = new google.maps.Marker({
position : latlng,
map : map,
id : point.id //Тут идентификатор маркера
});
google.maps.event.addListener(marker, 'click', function() {
console.log(marker.id);
$('[data-id="'+marker.id+'"]').show(); //Показываем блок с информацией о этом маркере
});
const input = document.querySelector('#textLink');
const buttonSelector = '.link';
document.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
input.value = button.innerText;
}
});
document.querySelectorAll(buttonSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => input.value = e.currentTarget.textContent);