Remove function doesn't works jquery : i'm trying to use this jquery function:

$('a').filter(function(index) { return $(this).text() === oEvent.getSource().getTarget().split("/")[0]; }).nextAll().remove();

This function is called when i press a link in a toolbar and i want to remove all next link in the toolbar but it doesn't work. When I press the link it seems to work because all next link are removed but istantanely they reappear. I'm using sapui5 and i hate it. Someone has a solution or any other ideas?