Get duplicate id’s in DOM using jQuery
Get duplicate id’s in DOM using jQuery // Warning Duplicate IDs $(‘[id]’).each(function(){ var ids = $(‘[id=”‘+this.id+'”]’); if(ids.length > 1 && ids[0] == this) console.warn(‘Multiple IDs…
Get duplicate id’s in DOM using jQuery // Warning Duplicate IDs $(‘[id]’).each(function(){ var ids = $(‘[id=”‘+this.id+'”]’); if(ids.length > 1 && ids[0] == this) console.warn(‘Multiple IDs…
Create a new simple rule for jquery.validator plugin by doing something like this: jQuery.validator.addMethod(“greaterThanZero”, function(value, element) { return this.optional(element) || (parseFloat(value) > 0); }, “*…
Here is a bookmark script using jQuery: <script language=”javascript” type=”text/javascript”> $(document).ready(function(){ $(“a.jQueryBookmark”).click(function(e){ e.preventDefault(); // this will prevent the anchor tag from going the user off…
jQuery – preview button in new tab(window), target blank <!– DOCTYPE –> <html> <head> <title>jQuery – preview button in new tab(window), target blank</title> <script src=”http://code.jquery.com/jquery-latest.js”></script>…
jQuery Ajax – send all fields data by “POST” jQuery.ajax({ data: jQuery(‘#formId’).serialize(), // etc.. }
Verify if a checkbox is selected (checked) with jQuery <form name=”my_form_name” id=”my_check_box”> <input type=”checkbox” name=”my_check_box” id=”my_check_box”> </form> <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#my_check_box’).click(function () { if…
Method to prevent form submitting using jQuery: <form method=”post” name=”my_form_name” id=”my_form_id”> <input type=”submit” value=”Go”> </form> <script type=”text/javascript”> jQuery(‘#my_form_id’).submit(function() { alert(‘Prevent form submitting.’); return false; });…
Perform an Ajax request with jQuery: jQuery.ajax({ url: ‘url_of_ajax_request’, success: function(response) { alert(‘Response from url is: ‘ + response) } }); Source: JQuery Ajax