2

I cannot get the blur() function in the following to work:

$('.newselect').focus(function(){
    $(this).parent().append('<div class="select_container"></div>');
});
$('.newselect').blur(function(){
    $(this).parent().remove('.select_container');
});

However if I use a universal selector $('*') (as below) it works, why is this and how can I fix the problem?

$('.newselect').focus(function(){
    $(this).parent().append('<div class="select_container"></div>');
});
$('.newselect').blur(function(){
    $('*').remove('.select_container');
});
Phil
  • 225
  • 4
  • 13

1 Answers1

2

Try this:

$('.newselect').focus(function(){
    $(this).parent().append('<div class="select_container"></div>');
}).blur(function(){
    $(this).siblings('.select_container').remove();
});
PetersenDidIt
  • 25,562
  • 3
  • 67
  • 72