Reputation: 117
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
Upvotes: 0
Views: 3601
Reputation: 85653
You can use insertBefore
$('<span class="tag">sd<button class="close" type="button">×</button></span>')
.insertBefore('#form-field-tags');
Upvotes: 1
Reputation: 3200
try with:
$('input.tags').prepend('<span>what you want</span>');
Upvotes: 0
Reputation: 82241
Use .prepend()
:
$('div.tags').prepend('<span class="tag">sd<button class="close" type="button">×</button></span>')
Upvotes: 0
Reputation: 38112
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>');
Upvotes: 0