Having trouble capturing text of Data element using JQuery

I used the following and it worked well for my needs…

$('#hero-btn-group a').click(function() {
  var heroIntro = $(this).parents('div:has(#hero-btn-group)');

  if (heroIntro.length) {
    s.eVar52 = $("h1", heroIntro).attr('data-mb-name');
    console.log(s.eVar52);
 
  } else {
    // Don't follow the link
    S.eVar52 = "Contact Me"
    return false;
  }
});

Thanks @Paul_Wilkins