JavaScript
// find elements by class name
// var elements = $('.book');
// <div>Hello!</div>
// iterate through all the elements
elements.each( function(i, elem)
{
/* to do something */
});
Html
<html>
<!-- heading -->
<head>
<meta charset="utf-8">
<title>Example</title>
</head>
<!-- page -->
<body>
<!-- connect the library jQuery -->
<script src="https://dir.by/example_lib/jquery/jquery-3.3.1.min.js"></script>
<!-- HTML Elements -->
<div class='book'>
Book 'Journey'
</div>
<div class='cinema'>
Film 'Comedy'
</div>
<div class='book'>
Book 'Rest'
</div>
<!-- JavaScript -->
<script>
// the page has opened
$( function()
{
// iterate through all the elements with the desired class
$('.book').each(function(i, elem)
{
// show the contents of the item on the screen
alert($(elem).html());
});
});
</script>
</body>
</html>