Skip to content

Author: admin@master

key up jQuery removing class

Demo I have here a demo on validating if a class exist in a div. when there is no class another class is removed from a button. Basically what this does is when there are no disabled button the disable on add button will be removed. This works fine if the last thing user will do is change but if

How to make slow the Scroll-Top Speed

ScrollTop is a jquery plugin (go to top of page), trying to make slow Scroll Speed, but not working. I have changed scrollSpeed : ‘fast’, to scrollSpeed : ‘slow’, but it still fast, nothing change. JS: Call: How to make it slower or smoother, when it go to top? Answer use jquery animat…

Longest palindrome in a string

I wrote the following function to find the longest palindrome in a string. It works fine but it won’t work for words like “noon” or “redder”. I fiddled around and changed the first line in the for loop from: to and now it works, but I’m not clear on why. My intuition is tha…

Ternary shorthand for foo ? foo : bar

I realized I am using the ternary operator most of the time as following: foo ? foo : bar; This becomes cumbersome, as the variable length gets quite long, e. g. appModel.settings.notifications ? appModel.settings.notifications : {}; Is there any shorthand or more elegant way of doing this? Perhaps ES6 or ES7…