V
V
Viktor2015-10-17 16:33:31
JavaScript
Viktor, 2015-10-17 16:33:31

How to set existence check for multiple urls?

there is a code and you need to check for several urls, how to do it right?

$('a').each(function(){
if($(this).css('background-image')=='url(" www.like4like.org/img/icon/earn-twitter-antibot. png ")' {
$(this).parent().remove();
}
}); For example,

you need to add this url also

" www.like4like.org/img/icon/earn-facebook-like-anti... "

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2015-10-17
@Deonisius

You can try to create an array and use indexOf()

var urls = [
    'url(google.com)',
    'url(yandex.ru)'
];

if( urls.indexOf($(this).css('background-image')) !== -1 ) {
    // есть
}
Just keep in mind that the difference even in one character may not lead to the result you hope for. For example, if in one case the protocol is registered, but not in the other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question