9 июня 2021
Нет комментариев
$(".element").prop("clientWidth"); //или $(".element").prop("scrollWidth");
вместо
$('.element').width()
$(".element").prop("clientWidth"); //или $(".element").prop("scrollWidth");
вместо
$('.element').width()
(function($){ $.widget("ui.onDelayedKeyup",{ _init:function(){ var self=this; $(this.element).keyup(function(){ if(typeof(window['inputTimeout'])!="undefined"){ window.clearTimeout(inputTimeout); } var handler=self.options.handler; window['inputTimeout']=window.setTimeout(function(){ handler.call(self.element) },self.options.delay); }); }, options:{ handler:$.noop(), delay:500 } }); })(jQuery); $('header .search input[type=text]').onDelayedKeyup({ handler:function(){ var string=$(this).val(); if(string.length>3){ //....... } }, delay:1000 });
$('header nav ul li').hover(function(){ var li=$(this); this.timeout=window.setTimeout(function(){ li.addClass('hover'); },200) },function(){ $(this).removeClass('hover'); if(this.timeout){ window.clearTimeout(this.timeout); } });
$('textarea').each(function(){ var len=$(this).val().length; if(len>220){ $(this).css('border-color','red'); } }); $('textarea').on("keyup",function(event){ var len=$(this).val().length; $(this).next('span').html(len); if(len>220){ $(this).css('border-color','red'); } else{ $(this).css('border-color','#c5c5c5'); } });
Чтобы выполнить следующее действие полсе завершения fadeOut
$('.catalog .item').hover(function(){ $(this).find('source').remove(); var photo2=$(this).data('photo2'); if(photo2!=''){ var img=$(this).find('.photo a img'); img.fadeOut(400,function(){ img.attr('src',photo2); img.fadeIn(400); }); } },function(){ var photo1=$(this).data('photo'); if(photo1!=''){ var img=$(this).find('.photo a img'); img.fadeOut(400,function(){ img.attr('src',photo1); img.fadeIn(400); }); } });
вместо
$('.catalog .item').hover(function(){ $(this).find('source').remove(); var photo2=$(this).data('photo2'); if(photo2!=''){ $(this).find('.photo a img').fadeOut(400).attr('src',photo2).fadeIn(400); } },function(){ var photo1=$(this).data('photo'); if(photo1!=''){ $(this).find('.photo a img').fadeOut(400).attr('src',photo1).fadeIn(400); } });
$(document).on('click','.addresses .delete a',function(){ $(this).closest('.address').remove(); return false; });
вместо:
$('.addresses .delete a').on('click',function(){ $(this).closest('.address').remove(); return false; });
$('.block_4,.block_5').each(function(){ var img=$(this).find('.wrap').css('background-image'); img=img.replace('url(','').replace(')','').replace(/\"/gi,""); $(this).find('.wrap').css('background-image',''); console.log(img); $('<div class="photo"><img src="'+img+'" alt=""/></div>').insertAfter($(this).find('.title')); });