jquery - bigktmbig/MyExperienceAlgorithm GitHub Wiki
======================================================stop href a
Cachs 1:
$.ajax({
type:'POST',
url:'http://35.246.38.47:5000/predict',
headers : {
'Content-Type': 'application/x-www-form-urlencoded'
},
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
processData: false,
data : 'json=' + JSON.stringify(json),
success : (res)=>{
console.log(res);
},
error : (e)=>{
console.log(Error at : ${e})
}
});
==============================================2019/02/12 datetimepicker bootstrap inorge input readonly
===========================================2019/02/11 scroll from bottom to top const is_Mobile = !!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && !window.MSStream;
if(is_Mobile) {
$('#div_id').css('top','1500px');
$('#div_id').animate({top: '0px'}, 350);
}
===================================2019/01/04 : find element by class and data attribute $('.btn-reply[data-parent-id=' + parent_id + ']') ========================================2018/12/27 colorbox
-
js: function showPopup(href, callback, width, height) { if(width == undefined || (window.innerWidth<900 && width.indexOf('px')!==-1) ){ width = '90%'; } if(height == undefined){ height = '90%'; } var properties = { href : href, open : true, iframe : true, fastIframe : false, opacity : 0.2, escKey : true, overlayClose : false, innerWidth : width, innerHeight : height, reposition : false, speed : 0, fixed: true, onOpen: function() { if (is_IOS) { var ycoord =
$(window).scrollTop(); $ ('#colorbox').data('ycoord',ycoord); ycoord = ycoord * -1; $('body').css('position','fixed') .css('left','0px') .css('right','0px') .css('top',ycoord + 'px') .css('overflow', 'hidden'); } }, onComplete : function() {if (is_IOS) { widthWindow = $(window).width(); widthColorBox = $('#colorbox').width(); $('#colorbox').css('left', (widthWindow-widthColorBox)/2); // $('#colorbox').css('overflow', 'visible'); }else { $('#colorbox-width').val(width); $('#colorbox-height').val(height); } }, onClosed : function() { if (is_IOS) { $('body').css('position','') .css('left','auto') .css('right','auto') .css('top','auto') .css('overflow', 'auto'); $(window).scrollTop($('#colorbox').data('ycoord')); } if (callback) { callback(); } }
}; $.colorbox(properties); }
-
css: html,body{ -webkit-overflow-scrolling : touch !important; height: 100% !important; } ================================================ add custom method validation
$(document).ready(function () {
$.validator.addMethod("regex", function(value, element, regexpr) {
return regexpr.test(value);
}, "Please enter a valid email.");
$("#register_form").validate({
// debug: true,
rules: {
"user[first_name]": {required: true},
"user[last_name]": {required: true},
"user[email]": {required: true, regex: /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/ },
"user[password]": {required: true, minlength: 8, maxlength: 20},
"user[password_confirmation]": {required: true, equalTo: "#password"}
}
});
});
hide modal
scroll call ajax var loading = true; $(window).scroll(function(){ if(loading==true){ if(($(window).scrollTop()+$(window).height())>($('#container_categories').height() + 523)){} })
find and set value by class name $('#categories_filter_'+categories[i_jc]+' select.prices').on('change', function (evt) { $(this).parents('.freshspoke-header-section__filter_select').find('input.filter-pri').val(evt.target.selectedOptions[0].value); });
add/remove loading.gif when it's call ajax
- $(document).find('#categories_slider_'+cate).html('');
- $(document).find('#theImgProduct').remove();
find a class(ac, ad) in every class(ab) .js: $(".ab").eq([idx]); //idx is serial of ab class .html:
$('.plus').on('click', function() { clearTimeout(clickTimeout);
var oldVal = $('input').val();
var newVal = (parseInt($('input').val(),10) + 1);
$('input').val(newVal);
clickTimeout = setTimeout(function(){
$('#output').text($('input').val()); // replace with your update code
}, 500);
}); });
- HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" class="plus">+</button>
<input type="text" value="1">
<div>Updates on last click: <span id="output">1</span></div>
=============================================2020/02/26 draft unsave data