2

On a base of this question i'd like to ask a question: How can solve the same problem using class selector $('.class')?

I get Uncaught TypeError: undefined is not a function

When trying to run this

$('html, body').animate({
    scrollTop: $('input.ng-invalid').offset().top
}, 2000);
Community
  • 1
  • 1
Ilya Libin
  • 1,515
  • 2
  • 17
  • 36

2 Answers2

2

Try this

var sc = $('div[class="classname"]').offset().top;
        $('body,html').animate({
            scrollTop: (sc - 30)
        },
        'slow');
Manoj
  • 4,593
  • 2
  • 25
  • 54
1

I am not sure, but this is what you want? http://jsfiddle.net/65q6xo95/1/

$('html, body').animate({
    scrollTop: $('.ng-invalid:first').offset().top
}, 2000);
Paulo Segundo
  • 438
  • 3
  • 6