Check click target using jQuery

$(document).click(function(event){     
	$target = $(event.target);
	if(!$target.closest('.div-content').length){
		alert('outside');
	}else{
		alert('inside');
	}
});

jQuery validation to allow only numbers OR only characters

Allow only numbers 
$(‘#zip’).keypress(function(event){

if(event.which != 8 && isNaN(String.fromCharCode(event.which))){

event.preventDefault();

}
});

Allow Characters with dots
$(‘#name’).keypress(function(event){

var inputValue = event.charCode;  if(!(inputValue >= 65 && inputValue <= 120) && (inputValue != 32 && inputValue != 0  && inputValue != 46)){

event.preventDefault();

}

});

Divs swapping based on window width & screen rotate

$(document).ready(function(){
/*Based on window width*/
if ($(window).width() < 767) {
$(“.mob-align-right”).insertAfter(“.mob-align-left”);
}

/*Sreen rotate event*/
$(window).on(“orientationchange”,function(){
if($(window).width() > 767){
$(“.mob-align-right”).insertAfter(“.mob-align-left”);
}else{
$(“.mob-align-left”).insertAfter(“.mob-align-right”);
}
});
});

Cursor suddenly jumping from textarea

If we use typejs in our document this type of issue will occur find below code to fix.
$(“.textarea”).bind(‘keypress’, function(e) {
if(e.which == 32){
var textarea_val = $(“.textarea”),
val_ask = textarea_val.val();
textarea_val.focus().val(“”).val(val_ask);
}
});