开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜