Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery remove specific children

I have the following code :

$('.TopNotificationIcon span').remove();    

Can I replace .TopNotificationIcon with this i.e only span exists inside this specific class.

This is the structure

<div class="TopNotificationIcon"><span>xxxxx</span></div>

On click of .TopNotificationIcon, span should be removed.

like image 542
aWebDeveloper Avatar asked May 24 '11 15:05

aWebDeveloper


1 Answers

if you have click event for .TopNotificationIcon you can do something like this

$('.TopNotificationIcon').click(function(){
    $('span',this).remove();    
});
like image 119
Jishnu A P Avatar answered Nov 14 '22 09:11

Jishnu A P