Skip to content

Tag: jquery

Round number to two decimals

I’m trying to use Math.round for the total to show only two decimals, but it doesn’t work as intended. What am I doing wrong? Since I’m using float, the numbers sometimes get changed into long decimals instead of the exact amount. I’m trying to prevent this by using Math.round. If anyo…

hide sidebar when click anywhere in page

I have an animate sidebar which appears when user clicks on a hamburger button. Here is the structure : Actually we can open menu by clicking on #nav-toggle element and close it by clicking on this element too. I’d like to allow user to close this menu by clicking anywhere in the page. How can I do do t…

Datatables rowId starting with a number issue

According to the Datatables specs, I can add a unique ID to every row in my table: However, the same spec says that IDs cannot start with a number. staffIdin my case is a number, I tried to add some prefix to it: However, this didn’t work. Any ideas? Answer Use function-expression as a value for rowId a…