0

Good evening,

this is what I'm trying to achieve: on AJAX 'success' the page has to jump to a generated anchor.

this is the AJAX:

    success: function(html){  

// Refresh certain files

$pc("#load_comments").load("core/comments/view_comment.php")
     $pc("#replyid").val('');
     $pc("#replyat").val('Write a comment');
     $pc("#comment").val(''); 

// Jump to anchor function


  }

The page has to jump this anchor

<a name="lcn_post' .($id). '"></a> 

Any ideas? I've tried a few ideas but no success yet.

Thanks in advance :)

Sumurai8
  • 20,333
  • 11
  • 66
  • 100
Maarten Hartman
  • 1,611
  • 6
  • 26
  • 45
  • Are you looking for something like [`scrollIntoView`](http://stackoverflow.com/a/2368393/317849)? – sdleihssirhc Jan 25 '12 at 01:36
  • I tried: success: function(html){ // Refresh certain files $pc("#load_comments").load("core/comments/view_comment.php") $pc("#replyid").val(''); $pc("#replyat").val('Write a comment'); $pc("#comment").val(''); document.getElementById('lcn_post" + id +"').scrollIntoView(); } but doesn't work, or is the code wrong? – Maarten Hartman Jan 25 '12 at 02:08

1 Answers1

0

Try:

$("[name='lcn_post" + id +"']").focus();

it's in jQuery notation.

travega
  • 8,284
  • 16
  • 63
  • 91
  • have you anything else on the page steeling .focus()? Make sure that you are trying to .focus() on your element after it has been generated. – travega Jan 25 '12 at 02:09