How use jQuery to append a element to the right side of another element?
I have
<input type='text', id='name'></input>
and I have
<p>my name is xyz</p>
I would like the <p>
element to be located 20px the right side of <input开发者_Python百科>
, how to use jQuery to achieve this?
$('<p></p>').html('my name is xyz').css('margin-left', '20px').insertAfter($('#name'));
or
$('/*select p*/').css({'margin-left':'20px'}).after($('#name'));
Or just put css
p{
margin-left: 20px;
}
精彩评论