jQuery function jQuery is a type of JavaScript programming script used in website development. jQuery is very strict in its syntax .Programmers are writing jQuery functions for doing specific tasks. Syntax of JQuery function is //start <script type=”text/javascript”> $(“#username”).keydown(function(event) { }); </script> //end function This is a keydown function
Tag: jQuery
How to loop through array in jquery
if(jQuery.trim(jQuery(“#custom-email-input”).val()) != ”) { var sCustomemails = jQuery(“#custom-email-input”).val().split(‘,’); jQuery.each(sCustomemails, function(index, email) { if(!validEmail(email)) { jQuery(“#custom-email-input”).addClass(‘error’); alert(‘Please enter only valid email addresses.’); jQuery(“#custom-email-input”).attr(‘placeholder’,’Please enter only valid email addresses’); error=true; } else { jQuery(“#id_subject”).removeClass(‘error’); } }); }
How to explode a string to an array in javascript or jQuery
Using javascript or jQuery function split() for explode string to array Example: if(jQuery.trim(jQuery(“#custom-email-input”).val()) != ”) { var sCustomemails = jQuery(“#custom-email-input”).val().split(‘,’); alert(sCustomemails ); }
Kill a jQuery function using unbind()
Using The following jquery function to kill a function(unbind/bind) Syntax: jQuery(this).unbind(‘<function name>’); Example: jQuery(“#message_send”).live(“click”, function(){ jQuery(this).unbind(‘autosave’); });
parseInt in jQuery for type conversion
convert data type to integer in jquery. Some times need to convert type into integer for doing different kinds of numerical operations. syntax: parseInt(value); Eg : var smarterthanyou = parseInt($(“#yourname”).val());