Reputation: 2915
I want to put element under focus
just after append
it, means something similar to :
$("id").append($("elementid")).focus(); // not working
Upvotes: 1
Views: 125
Reputation: 31477
The jQuery ID selector needs a #
before the id.
So
$("#id").append($("#elementid")).focus();
should work if you want to put focus on your #id
DOM element, if you want to put focus on the #elementid
DOM element, then you can use VisioN's answer.
Upvotes: 2
Reputation: 145458
In your example you are adding focus to id
element, that's why it doesn't work.
Try this solution instead:
$("#elementid").appendTo("#id").focus();
DEMO: http://jsfiddle.net/wRSBY/
Upvotes: 3