D
D
del9937882016-04-07 09:21:06
JavaScript
del993788, 2016-04-07 09:21:06

How to remove a piece of code if a certain id is present on the page?

Hello. I'm trying to do this thing in dle: if there is any error on the page, then you need to remove a certain part of the code. The error has id "werror" . I wrote this code

if($("#werror")) {
   $('.fav').remove();
}


But it works even when there is no werror on the page. Tell me, where is the mistake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Outoverlay, 2016-04-07
@del993788

if( $("#werror").length > 0 )
$( '.fav' ).remove();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question