I posted a similar question but wasn’t sure if I should have included it there, or start a new question. If I should have included in the same question, I will gladly do so.
ON a click event I want to bbuble up and capture the text from (data-mb-name) in the Div id = Hero-intro at the top of the HTML I included above.
the html is the following… this is just a snippet, but is the portion of the HTML that I am concerned with.
<div id="hero-intro" class="col-sm-7 col-sm-offset-1">
<h1 id="mb-name" data-mb-name="Ann Arnesen">Ann Arnesen</h1>
<h3 id="hero-Title"><span>Sr. Mortgage Banker</span> | <span>NMLS #453374</span></h3>
<!-- #hero-title -->
<div class="sep-short-blue"></div>
<h5 id="hero-rating">Overall Satisfaction Rating:
<span class="rs rating-stars"><i class="fa fa-star fa-star-full"></i> <i class="fa fa-star fa-star-full"></i> <i class="fa fa-star fa-star-full"></i> <i class="fa fa-star fa-star-full"></i> <i class="fa fa-star fa-star-full"></i></span> <span class="rs rating-percent">5 out of 5</span> </h5>
<!-- #hero-rating -->
<p id="hero-intro-text">With over 10 years in the mortgage industry, Ann Arnesen has helped over 1,100 families achieve their dream of owning a home. The majority of Ann’s clients are repeat customers.</p>
<!-- #hero-intro-text -->
<div id="hero-readmore"><a href="#biography" data-toggle="modal">Read full bio...</a></div>
<!-- #hero-readmore -->
<div id="hero-btn-group">
<a class="btn-ghost-white btn-left page-scroll" href="#social-c">CONTACT ME</a>
<a class="btn-ghost-white btn-right" href="https://www.secureloandocs.com/apply.php?id=36309094&loId=16167" target="_blank">APPLY ONLINE</a>
</div>
<!-- #hero-btn-group -->
</div>
this is the JQuery script I wrote, but is not working correctly. Basically on the click event I want to capture the data-mb-name attribute → in this case it would be Ann Arnensen.
$('.hero-btn-group a').click(function() {
var getElement = $(this).parents('Div:has(#hero-btn-group'));
if (getElement.length) {
// Do something here
s.eVar52 = ( getElement.attr('data-mb-name'));
console.log(s.eVar52);
} else {
// Don't follow the link
return false;
}
});
I’ve also tried the following
$('div:has(#hero-btn-group)').click(function() {
var getElement = $(this).parents('div:has(#hero-intro)');
$('div:has(#hero-btn-group) a').click(function() {
var getElement = $(this).parents('div:has(#hero-intro)');
$('div:has(#hero-btn-group a)').click(function() {
var getElement = $(this).parents('div:has(#hero-intro)');
Nothing seems to work. @m3g4p0p