0

I want to add span to div code below to understand my problem

<div class="tags">
**<span class="tag">sd<button class="close" type="button">×</button></span>**
<input type="text" placeholder="Enter tags ..." id="form-field-tags" name="tags" style="display: none;"><input type="text" placeholder="Enter tags ...">
</div> 

**<span>** decribe place for insert one or many tag between div before input tag

4 Answers 4

1

You can use insertBefore

$('<span class="tag">sd<button class="close" type="button">×</button></span>')
.insertBefore('#form-field-tags');
Sign up to request clarification or add additional context in comments.

1 Comment

Insert a span but outside of div
0

You can use .prepend():

Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.

$('div.tags').prepend('<span class="tag">sd<button class="close" type="button">×</button></span>');

Fiddle Demo

Comments

0

Use .prepend():

 $('div.tags').prepend('<span class="tag">sd<button class="close" type="button">×</button></span>')

Comments

0

try with:

$('input.tags').prepend('<span>what you want</span>');

Comments

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.