jQuery Scroll to Div

Check this link: http://css-tricks.com/snippets/jquery/smooth-scrolling/ for a demo, I’ve used it before and it works quite nicely.

The preferred way of creating a new element with jQuery

The first option gives you more flexibilty: And of course .html(‘*’) overrides the content while .append(‘*’) doesn’t, but I guess, this wasn’t your question. Another good practice is prefixing your jQuery variables with $:Is there any specific reason behind using $ with variable in jQuery Placing quotes around the “class” property name will make it more compatible with less flexible browsers.

if-not condition fails (jQuery)

You need to check the number of elements found, as jQuery returns an empty collection in the event of no elements being found (which evaluates to a truthy value in the if statement): I’d suggest testing against 0 explicitly, rather than relying on a falsey value, though:

How to get current date in jQuery?

Date() is not part of jQuery, it is one of JavaScript’s features. See the documentation on Date object. You can do it like that: See this jsfiddle for a proof. The code may look like a complex one, because it must deal with months & days being represented by numbers less than 10 (meaning the strings will have one char instead of … Read more