React Component with Children
Creating a React component that contains children can be as easy as including a children property and including {props.children} in the Return function. But knowing the proper type to use [...]
Creating a React component that contains children can be as easy as including a children property and including {props.children} in the Return function. But knowing the proper type to use [...]
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 [...]
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 [...]
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.'); }
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 [...]
When a DOM object is added after the DOM has loaded, the usual process of binding an event to a specific jQuery object may not be sufficient. E.g.: Normal binding [...]
$.post('status.ajax.php', {deviceId: id}) .done( function(msg) { ... } ) .fail( function(xhr, textStatus, errorThrown) { alert(xhr.responseText); }); http://stackoverflow.com/a/12116790/4669143
Do something after jQuery resize or scroll is done, or has paused. Instead of firing the event every time the resize/scroll is detected, which is constantly during a resize/scroll operation, [...]
$("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
if ($(selector).length) { // Exists } Source: http://stackoverflow.com/a/587408