-3

I have the html div below:

var htm_div = slider.target;

console.log(html_div); //Returns the html div

<div id="layerslider_2" class="ls-wp-container fitvidsignore ls-v6 ls-container ls-responsive ls-device-is-desktop" style="width: 343px; height: 193px; margin: 0px auto; position: relative; visibility: visible;" data-layerslider-uid="LSzclf85rp7" data-current-slide="4">
  <div>....</div>
  <div>....</div>
  <div>....</div>
</div>

Using javascript or jQuery, I want to get the id value of this div. How to achieve this and thanks.

user3383728
  • 75
  • 2
  • 12

1 Answers1

1

html_div.id will give you access to the value of the id attribute using vanilla javascript.

Sasha K.
  • 287
  • 2
  • 8