$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
$('a[href*=#]:not([href=#])').click(function(e) {
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
e.preventDefault();
}
}
});
Что надо сделать
option.each(function(i, item){
list.append('<li>' + $(item).text() + '</li>');
});
//Установит всем .selected на странице значение первого select'a
selected.text(select.val());
//Если первый .selected на странице имеет класс focus, скрыть все существующие списки
container.click(function(){
if(selected.hasClass('focus')){
list.slideUp(300, function(){
selected.removeClass('focus');
});
return;
};
list.slideDown(300);
selected.addClass('focus');
});
$(document).click(function(e) {
$(e.target).closest(".select").length||
$(".focus").removeClass("focus")
.next(".list").slideUp(300);
});
<a>
у его контейнера<li>
есть вложенный список - раскрыть список, по ссылке не переходить, иначе перейти по ссылке в кликнутом элементе.$("#mli_open").parent(".mli_toggle").parent(".mli").click
- неправильно, т.к. у вас каждый раз навешивается обработчик при клике на topMenu, надо $("#mli_open").parent(".mli_toggle").parent(".mli").off().click
. А лучше не навешивать его внутри другого обработчика. jQuery('.js-iframe-load').each(function(){
setTimeout((function(){ $(this).attr('src', $(this).attr('data-src-frame') ); }).bind(this) , 2000)
})
var props = {};
$.ajax({
url: 'https://randomuser.me/api/',
dataType: 'json',
success: function(data){
var user = data.results[0].user,
list = $('.form-control'),
prop;
deepSearch(user);
for (var i = 0, len = list.length; i < len; i += 1) {
prop = props[ $(list[i]).attr('id') ];
if ( prop ) $(list[i]).val(prop);
}
}
});
function deepSearch(node) {
for (var elem in node) {
if ( typeof node[elem] !== 'object' || isObjectEmpty(node[elem]) ) {
props[elem] = node[elem];
} else {
deepSearch(node[elem]);
}
}
}
function isObjectEmpty(obj) {
for (var key in obj) {
return false;
}
return true;
}
$("input[type=text]").each(function() {
var input = $(this), id = this.id;
input.attr('name', id);
});
<span id="nextLabel">SLPK</span>
<input type="text" value="3" data-label="minSl" name="min_bedrooms" class="form-control" placeholder="Typ of selecteer..." data-original-title="" title="">
<input type="text" value="4" data-label="maxSl" name="max_bedrooms" class="form-control" placeholder="Typ of selecteer..." data-original-title="" title="">