i want use append for first $class, how is it?
var $class = '.' + $(this).closest('div.find_input').find('div').attr('class');
$(this).closest($class).find('.adda:first-child .mediumCell').append('<a href="" class="add_input"></a>')
EDIT: this my full code:
$('a.remove_input').live('click', function (event) {
event.preventDefault();
var $class = '.' + $(this).closest('div.find_input').find('div').attr('class');
$(this).closest($class).prev().find('.adda .mediumCell').first().append('<a href="" class="add_input"></a>')
$(this).closest($class).remove();
});
html:(i use of several html and several $class)
<div class="column find_input">
<div class="add_units">
<div class="mediumCell">
<input type="text" name="price" placeholder="hello" class="numeric" style="width: 70px;">
</div>
<div class="column adda" style="margin: 5px 1145px 0 0; position: absolute; float: left;">
<div class="mediumCell">
<a href="" class="add_input">add</a>
</div>
</div>
</div>
</div>
Well to select the first element of a set of matched elements just use first().
Doc is here: http://api.jquery.com/first/
The following should add the link to the first $class only: