Jump to content
  • 0

Scroll к форме по клику на кнопку


npofopr
 Share

Question

Привет.

Как сделать, чтобы при клике на кнопку Пожаловаться, фокус переходил на форму.

Использовать какие то scrollTo или есть что то проще?

http://codepen.io/npofopr/pen/mdtae

 

Попробовал вот так 

http://www.dconnell.co.uk/blog/index.php/2012/03/12/scroll-to-any-element-using-jquery/

http://stackoverflow.com/questions/6677035/jquery-scroll-to-element

но не получилось.

 


Или не срабатывает, потому что форма скрыта?

Edited by npofopr
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

странненький сайтек, не привычно. CSS не видно, хтмл вроде получилось норм вид придать в js не увидел перехода к форме только привязка какого-то класса, которого даже нет в css...

Link to comment
Share on other sites

  • 0

странненький сайтек, не привычно. CSS не видно, хтмл вроде получилось норм вид придать в js не увидел перехода к форме только привязка какого-то класса, которого даже нет в css...

Потому что css берется с другого сайта. Мне просто не хочется выдирать и переносить все стили.

Вообще вот страничка http://shadow.perm.ru/test/pioneer/profile.html

Перехода к форме нет, потому что он и не получается. Выше вставил ссылки, что пробовал.

Link to comment
Share on other sites

  • 0

оно, не?

Оно.

 

И вот это сработало

$("#b_lk_review-add").click(function() {   $('html, body').animate({       scrollTop: $("#b_lk_review-form").offset().top   }, 200);});

А как еще поднять на 200px выше нужного блока. Т.е. примерно так сделать 

{scrollTop: '+=200px'}

только куда это всунуть.

 

Link to comment
Share on other sites

  • 0

я думаю что как-то так:

	$("#b_lk_review-add").click(function() {   $('html, body').animate({       scrollTop: $("#b_lk_review-form").offset().top   }, 200, function() {		Scroll-Top(); // тут вызываешь ф-цию, которая будет делать этот самый сдвиг на 200px вверх});

либо вот ссылка, там найдешь ответ.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy