Can jQuery add commas while user typing numbers?

Run the code snippet to see it work $(‘input.number’).keyup(function(event) { // skip for arrow keys if(event.which >= 37 && event.which <= 40) return; // format number $(this).val(function(index, value) { return value .replace(/\D/g, “”) .replace(/\B(?=(\d{3})+(?!\d))/g, “,”) ; }); }); <script src=””></script> <input class=”number”>

How do I drag multiple elements at once with JavaScript or jQuery?

var selectedObjs; var draggableOptions = { start: function(event, ui) { //get all selected… selectedObjs = $(‘div.selected’).filter(‘[id!=’+$(this).attr(‘id’)+’]’); }, drag: function(event, ui) { var currentLoc = $(this).position(); var orig = ui.originalPosition; var offsetLeft = currentLoc.left-orig.left; var offsetTop =; moveSelected(offsetLeft, offsetTop); } }; $(document).ready(function() { $(‘#dragOne, #dragTwo’).draggable(draggableOptions); }); function moveSelected(ol, ot){ console.log(selectedObjs.length); selectedObjs.each(function(){ $this =$(this); var pos … Read more

Twitter Bootstrap Collapse plugin Direction—Horizontal instead of Vertical

I figured out how to do this very easily without modifying or adding any javascript. First you define the following CSS after all Twitter Bootstrap CSS: .collapse { height: auto; width: auto; } .collapse.height { position: relative; height: 0; overflow: hidden; -webkit-transition: height 0.35s ease; -moz-transition: height 0.35s ease; -o-transition: height 0.35s ease; transition: height … Read more

jQuery multiselect drop down menu

Update (2017): The following two libraries have now become the most common drop-down libraries used with Javascript. While they are jQuery-native, they have been customized to work with everything from AngularJS 1.x to having custom CSS for Bootstrap. (Chosen JS, the original answer here, seems to have dropped to #3 in popularity.) Select2: Selectize: … Read more