Simplest way of getting the number of decimals in a number in JavaScript [duplicate]

Number.prototype.countDecimals = function () { if(Math.floor(this.valueOf()) === this.valueOf()) return 0; return this.toString().split(“.”)[1].length || 0; } When bound to the prototype, this allows you to get the decimal count (countDecimals();) directly from a number variable. E.G. var x = 23.453453453; x.countDecimals(); // 9 It works by converting the number to a string, splitting at the . … Read more

CSS selector for targeting only immediate children and not other identical descendants

ul > li only does the immediate children. So, for example, to do only the top level list elements you could use: #parent > li Note: this isn’t supported on IE6. The common workaround for backwards compatibility is to do something like this: #parent li { /* style appropriately */ } #parent li li { … Read more

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