0

I want to add an HTML input to this div:

<div class="sss" style="padding-top:2px"> 
<center> 
 <input value="test1" name="name1" type="submit" >  
<input value="test2" name="name2" type="submit">
  </center> 
</div>

I used this:

$(".sss").append('<input  onclick =loc(); value="test3" >');

It's working, but I want to add it between <center> tag. I used this code but it doesn't work and add it's after </center> tag.

$(".sss:first").append('<input  onclick =loc(); value="test3" >');

1 Answer 1

2
$(".sss center").append('<input  onclick =loc(); value="test3" >');

to put it in between input tags

$(".sss center :first-child").after('<input  onclick =loc(); value="test3" >');
// or $(".sss center :first").after('<input  onclick =loc(); value="test3" >');
// or $(".sss center :last-child").before('<input  onclick =loc(); value="test3" >');
Sign up to request clarification or add additional context in comments.

1 Comment

ad now how can i put it between input tags?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.