on focus add delete button
when an input with class="text" is focused i add a delete button to the parent element. But if there are more than 1 inputs with this class it adds several buttons on some of the parent elements. how do i prevent this?
- $j('.text').focus(function(){
var parts = $j(this).attr('id').split('-');
$j(this.parentNode).append('<input type="button" class="delete" value="del" id="delete-'+parts[1]+'" />');
});
$j('.text').blur(function(){
var parts = $j(this).attr('id').split('-');
$j('#delete-'+parts[1]).remove();
});