.map

get inner html of all li

by Dipak1991

HTML

<ul>
  <li>list item 1</li>
  <li>list item 2</li>
  <li>list item 3</li>
  <li>list item 4</li>
</ul>
<button id='getdata'>Get data</button>

CSS

.highlighted {
  background: #3c763d;
}

JavaScript

$('#getdata').on('click', function() {
  var data = $('li').map(function(index, element) {
    return $(this).html()
  }).get();
  console.log(data)
});