JavaScript

Prevent Link/Button Event or Post

Preventing a Link or Button from moving to the next URL (or triggering a post or postback in the case of ASP.Net) is easily accomplished using the very common method [...]

2019-03-28T15:37:49-03:00March 28th, 2019|

Pass Parameter to SetTimeout in JavaScript

It is sometimes necessary to pass a variable to a SetTimeout() callback function. By the time the callback occurs, the original variable may no longer exist, so passing a copy [...]

2019-02-12T00:30:09-04:00February 12th, 2019|

Check If Element Has ID Using jQuery

To check if an element has an ID: if ($(this).is('[id]') { // Has ID console.log('Has ID: ' + $(this).attr('id')); } else { // Has no ID console.log('Has no ID.'); }

2019-02-11T22:30:07-04:00February 11th, 2019|

jQuery – Selector Starts-Ends With

Selector Starts With: $('input[name^=somePrefix]').doSomething(); Selector ENDS with: $('input[name$=someSuffix]').doSomething(); In ASP.Net: This is particularly useful in ASP.Net when you may not want to specify clientidmode static, but still want to use [...]

2019-02-06T23:56:27-04:00August 6th, 2018|Tags: , |

jQuery – Get Ajax Post Error Details

$.post('status.ajax.php', {deviceId: id}) .done( function(msg) { ... } ) .fail( function(xhr, textStatus, errorThrown) { alert(xhr.responseText); }); http://stackoverflow.com/a/12116790/4669143

2019-02-06T23:57:31-04:00August 6th, 2018|Tags: |

jQuery – Enable or Disable Inputs

$("input").prop('disabled', true); $("input").prop('disabled', false); This will automatically add/remove the 'disabled' property of the element. Source: http://stackoverflow.com/a/1414366/4669143

2019-02-06T23:58:43-04:00August 6th, 2018|Tags: |
Go to Top