Toggle input disabled attribute using jQuery

$(‘#el’).prop(‘disabled’, function(i, v) { return !v; }); The .prop() method accepts two arguments: Property name (disabled, checked, selected) anything that is either true or false Property value, can be: (empty) – returns the current value. boolean (true/false) – sets the property value. function – Is executed for each found element, the returned value is used … Read more

Toggle Checkboxes on/off

You can write: $(document).ready(function() { $(“#select-all-teammembers”).click(function() { var checkBoxes = $(“input[name=recipients\\[\\]]”); checkBoxes.prop(“checked”, !checkBoxes.prop(“checked”)); }); }); Before jQuery 1.6, when we only had attr() and not prop(), we used to write: checkBoxes.attr(“checked”, !checkBoxes.attr(“checked”)); But prop() has better semantics than attr() when applied to “boolean” HTML attributes, so it is usually preferred in this situation.

How to getElementByClass instead of GetElementById with JavaScript?

The getElementsByClassName method is now natively supported by the most recent versions of Firefox, Safari, Chrome, IE and Opera, you could make a function to check if a native implementation is available, otherwise use the Dustin Diaz method: function getElementsByClassName(node,classname) { if (node.getElementsByClassName) { // use native implementation if available return node.getElementsByClassName(classname); } else { … Read more

Data-toggle tab does not download Leaflet map

Welcome to SO! If your Leaflet map suddenly works correctly after you resize your browser window, then you experience the classic “map container size not valid at map initialization”: in order to work correctly, Leaflet reads the map container size when you initialize the map (L.map(“mapContainerId”)). If your application hides that container (typically through CSS … Read more