JavaScript: Getting a DIV from a data attribute (using a class element)

From The Travis van der Font Wiki
Jump to: navigation, search
Using JavaScript
var div = $('.news').find('[data-custom-id=\''+index+'\']');
HTML Example
<div class="news">
  <div class="news-content" data-custom-id="1"">...</div>
  <div class="news-content" data-custom-id="2"">...</div>
</div>