jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
} );
const labels = document.querySelectorAll('#price_block .change_model_iphone .item label');
const select = document.querySelector('#select_model');
const getFor = el => el.getAttribute('for');
// или
const getFor = el => el.attributes.for.value;
// или
const getFor = el => el.htmlFor;
// можно перезаписать разметку
select.innerHTML = Array
.from(labels, n => `<option value="${getFor(n)}">iPhone ${n.innerText}</option>`)
.join('');
// или, напрямую создавать новые элементы
select.append(...Array.prototype.map.call(
labels,
n => new Option(`iPhone ${n.textContent}`, getFor(n))
));
<div class="text">hello, world!!</div>
<div class="text">fuck the world</div>
<div class="text">fuck everything</div>
<select></select>
const texts = document.querySelectorAll('.text');
const select = document.querySelector('select');
select.append(...Array.from(texts, n => new Option(n.textContent)));
select.value = null;
select.addEventListener('change', ({ target: { selectedIndex } }) => {
texts.forEach((n, i) => n.classList.toggle('active', i === selectedIndex));
});
$.ajax({
url: "https://spreadsheets.google.com/feeds/list/1NzcKjtoS-p_Gz6ILOa3JB1aVgoPMC7mgepWtz9uBmgo/od6/public/values?alt=json",
crossDomain: true, // это решает проблему с отсутствием Access-Control-Allow-Origin
dataType: "jsonp",
success: function(data){
console.log(data)
}
});
$("form").each(function(i, el) {
$(el).submit(function() {
let $that = $(this); // var $that = $(this); - для ES5
$.ajax({
url: $that.attr('action'),
type: 'POST',
data: {
contactemail: $that.find('input[type=email]').val()
},
success: function() {
$that.closest(".section").find(".bg_form_submit").slideToggle("slow");
alert("1");
$('form').trigger('reset');
},
error: function() {
alert("0");
}
});
return false;
});
});
function download(content, fileName, contentType) {
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
if($.fn.selectize) {
console.log('select select');
}
$('.slider').slick({
infinite: false,
});
.fancybox-infobar{
display: none;
}