开发者

How use jQuery to append a element to the right side of another element?

开发者 https://www.devze.com 2023-02-22 12:12 出处:网络
I have <input type=\'text\', id=\'name\'></input> and I have <p>my name is xyz</p>

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

精彩评论

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