Reputation: 38872
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>
, how to use jQuery to achieve this?
Upvotes: 1
Views: 4830
Reputation: 14318
$('<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;
}
Upvotes: 3