How to remove the white space at the start of the string

This is what you want: function ltrim(str) { if(!str) return str; return str.replace(/^\s+/g, ”); } Also for ordinary trim in IE8+: function trimStr(str) { if(!str) return str; return str.replace(/^\s+|\s+$/g, ”); } And for trimming the right side: function rtrim(str) { if(!str) return str; return str.replace(/\s+$/g, ”); } Or as polyfill: // for IE8 if (!String.prototype.trim) … Read more

Jquery datatables destroy/re-create

CAUSE When DataTables destroys the table because of the option destroy:true it restores original content and discards the content that you’ve generated. SOLUTION #1 Remove destroy:true option and destroy the table before you manipulate the table with destroy() API method. if ( $.fn.DataTable.isDataTable(‘#tblRemittanceList’) ) { $(‘#tblRemittanceList’).DataTable().destroy(); } $(‘#tblRemittanceList tbody’).empty(); // … skipped … $(‘#tblRemittanceList’).dataTable({ “autoWidth”:false, … Read more

jQuery: Single button click, click event firing two or more times

Your problem may be happening because you are assigning the same handler to the click event multiple times. I suggest you check that the line where you assign the handler is not being called multiple times inadvertently. Another solution could be a call to unbind (deprecated 3.0) or off (superseeded) first: $(“#myButton”).unbind(“click”).click(myHandler); // deprecated $(“#myButton”).off(“click”).click(myHandler); … Read more

Swapping rows in JQuery

Here’s another solution. To move a row down: jQuery(“#rowid”).next().after(jQuery(“#rowid”)); To move a row up: jQuery(“#rowid”).prev().before(jQuery(“#rowid”));

how to set active class to nav menu from twitter bootstrap

You can use this JavaScript\jQuery code: // Sets active link in Bootstrap menu // Add this code in a central place used\shared by all pages // like your _Layout.cshtml in ASP.NET MVC for example $(‘a[href=”‘ + this.location.pathname + ‘”]’).parents(‘li,ul’).addClass(‘active’); It’ll set the <a>‘s parent <li> and the <li>‘s parent <ul> as active. A simple solution … Read more

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