A
A
Anton Antipov2015-09-26 20:07:30
JavaScript
Anton Antipov, 2015-09-26 20:07:30

How to handle missing element in .map()?

For example, .athere is no class, how to handle the absence of an element?

var a = $('.a, .b').map(function () {
  return $(this).html();
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-09-26
@In4in

Maybe $(".a, .b").is(".a");?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question