I have an array with HTML Elements and I would like to addclass to the elements where his data-id is equal to ids in a array retrieve after an ajax called. I explain, I have this :
function update_b() {
  var $bookIds = $(".js-book").map(function() {
    return $(this).data("id");
  }).get();
  $.ajax({
    type: 'GET',
    url: ajaxurl,
    data: {
      action: 'verify_books',
      books: $bookIds
    },
    success: function(data){
      if(data) {
     // if ID in data is the same as data-id in the $books
     //   $books.addClass('is-active');
      }
    },
  });
And I have this in PHP to verify if the boosk are in my data
function verify_boos(){
  $books = $_GET['books'];
  $userId = get_current_user_id();
  $library = get_user_meta($userId, 'library', true);
  return array_intersect($books, $favoris);
}
When I log data in my success function I have for example an array with two Ids of books. I want to addClass on these two buttons who have the same id in "data-id". How can I do this ?
 
     
    