質問

i have following html i want to access "ABC" of h6 element on click event of div element of class "tobook". this code is generated dynamically on some controll's event how to do this ? thanks in advance.

<div class='shortcut-tiles seatdata tiles-success tobook'>
       <div class='tiles-body seatmap'>
          <span style='display:none' class='type'>Sleeper</span>
          <span style='display:none' class='seatid'> 302</span>
          <a href='#'  >
              <center>
                 <h6 data-type='text' data-title='E' class='sno' style='color:white font-size:14px !important;'> 
                   ABC</h6>
                 </center>
          </a>
        </div>
</div>
役に立ちましたか?

解決

Try this

$(document).on('click', '.tobook', function () {
    var text = $(this).closest('.tobook').find('h6.sno').text();
    alert(text);
});

DEMO

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top