Is this code correct?

function gotoPage(id) {
    ("html, body").animate({
        scrollTop: $("."+id).offset().top
    }, 2000);
}

What I am trying to do is. That I created DIVs, with 100% of height, they have certain classes ..
I included jQuery, and I wanted to click on anchor and scroll to that certain page.
<a href="#" onClick="gotoPage(id that I want scroll to)">Lipsum</a>

Does it work? Nope.
What's wrong with it?

Does it work? Nope.
What's wrong with it?

A very good tool when writing front-end code is the developer console. Chrome and Firefox have this built in. I would encourage you to seek it out and use it religiously. You'll catch any and all JavaScript errors and where they're occuring. You can also then use console.log() to track down pesky issues throughout your script.

Anyways, two issues with your code:

("html, body").animate({

You need to begin this statement with the $ character. Otherwise you're going to get an error about an undefined function.

$("."+id)

This is actually going to search all elements for those with a class of the given ID. Not ID, as you're intending. The selector notation for an ID is the pound sign (#)- just as it is in CSS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.