Reputation: 1694
<ul id="content">
<li>
<label class="desc">Album Title:</label>
<div>
<input type="text" class="field text full required" name="album[title]" id="album_title" />
<?php echo form_error('album[title]', '<label class="error">', '</label>'); ?>
</div>
</li>
<li>
<label class="desc">Image</label>
<div>
<input type="file">
<a href="" id="add_row"><img src="<?php echo base_url(); ?>skin/images/add.png" /></a>
</div>
</li>
<li class="buttons">
<button id="saveForm" class="ui-state-default ui-corner-all" value="Submit" type="submit">Add</button>
</li>
</ul>
i want to add new <li>
before last <li>
for add dynamic image field(through jquery).
Thanks in advance Loganphp
Upvotes: 2
Views: 926
Reputation: 8463
Try This
$('#content li').last().insertBefore("<li></li>");
In This way u can append many li before last li
Updated U can also use this
$('#content li:last').insertBefore("<li></li>");
Upvotes: 1
Reputation: 46477
You could try using the jQuery insertBefore() method.
$('<li><input type="image" /></li>').insertBefore($('.buttons'));
Upvotes: 2