html - jquery identify which div is clicked -
i have 4 divs in 1 main div. no div has id. want identify div clicked jquery.
below html code have.
<div class="body"> <div class="summery-item-widget">details 1</div> <div class="summery-item-widget">details 2</div> <div class="summery-item-widget">details 3</div> <div class="summery-item-widget">details 4</div> </div>
thank in advance.
you can use this
keyword in event handler reference clicked element:
$('.summery-item-widget').click(function() { var text = $(this).text(); console.log(text); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="body"> <div class="summery-item-widget">details 1</div> <div class="summery-item-widget">details 2</div> <div class="summery-item-widget">details 3</div> <div class="summery-item-widget">details 4</div> </div>
Comments
Post a Comment