# Tag Info

3

Use variable for element, toggle can take multiple classes, use minimal selector. var voteButton; if(type === 'down'){ voteButton = $('.i-down-' + commentid); voteButton.toggleClass('active-color opacity-initial'); } else { var voteButton =$('.i-up-'+commentid); voteButton.toggleClass('primary-color opacity-initial'); } if(voted === '...

3

There's certainly nothing wrong with using a cookie for this, but it is, alternatively, entirely possible to monitor open tabs on the client side, using localStorage. The example below listens for page load and unload events: when a page is loaded, a new entry is added to localStorage when a page is unloaded, the last entry is removed from localStorage If ...

1

Move your revert all logic to the top of the function to avoid having to exclude the newly active item. Use a stateful class such as .is-active instead of message-head-active. Means you only have to toggle 1 class rather than 2. toggleClass accepts multiple arguments so you can toggle the FontAwesome classes in one line. This also removes the need for the ...

1

For those who dont like typed.js, Modified code for the user code is. Here, content -> is the text that shows the typing effect. speed -> is the typing effect speed. i -> this will help in iterating over the content till it reaches the content length. timer -> we use this variable to assign the setTimeout(), so that after the text content is looped, ...

Only top voted, non community-wiki answers of a minimum length are eligible