Let’s say I have this markup:
First paragraph
-
There's no problem with your code, it's just that a paragraph or div tag can't receive focus. Focus can only be given to things you can interact with, such as links, input elements, textareas, etc.
To scroll the window to this newly added element, you can use a plugin such as ScrollTo.
On a side note, your code could be simplified a bit:
var html = "New paragraph
";
$("#content").append(html);
$("#newP p").focus();
var html = "New paragraph
";
$(html)
.appendTo('#content')
.focus() // or scrollTo(), now...
;