Difference between .on(‘click’) vs .click()

I think, the difference is in usage patterns. I would prefer .on over .click because the former can use less memory and work for dynamically added elements. Consider the following html: <html> <button id=”add”>Add new</button> <div id=”container”> <button class=”alert”>alert!</button> </div> </html> where we add new buttons via $(“button#add”).click(function() { var html = “<button class=”alert”>Alert!</button>”; $(“button.alert:last”).parent().append(html); … Read more

How to use radio on change event?

You can use this which refers to the current input element. $(‘input[type=radio][name=bedStatus]’).change(function() { if (this.value == ‘allot’) { // … } else if (this.value == ‘transfer’) { // … } }); http://jsfiddle.net/4gZAT/ Note that you are comparing the value against allot in both if statements and :radio selector is deprecated. In case that you are … Read more

Bind a function to Twitter Bootstrap Modal Close

Bootstrap 3 & 4 $(‘#myModal’).on(‘hidden.bs.modal’, function () { // do something… }); Bootstrap 3: getbootstrap.com/javascript/#modals-events Bootstrap 4: getbootstrap.com/docs/4.1/components/modal/#events Bootstrap 2.3.2 $(‘#myModal’).on(‘hidden’, function () { // do something… }); See getbootstrap.com/2.3.2/javascript.html#modals → Events

How to change the text of a button in jQuery?

Depends on what type of button you are using <input type=”button” value=”Add” id=’btnAddProfile’> $(“#btnAddProfile”).attr(‘value’, ‘Save’); //versions older than 1.6 <input type=”button” value=”Add” id=’btnAddProfile’> $(“#btnAddProfile”).prop(‘value’, ‘Save’); //versions newer than 1.6 <!– Different button types–> <button id=’btnAddProfile’ type=”button”>Add</button> $(“#btnAddProfile”).html(‘Save’); Your button could also be a link. You’ll need to post some HTML for a more specific answer. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)