0

I am using angular for our application. how to get the parent element of tag.

<button _ngcontent-ulk-c11="" class="btn cust-btn blm-cust-btn active" type="button" ng-reflect-klass="btn cust-btn blm-cust-btn" ng-reflect-ng-class="[object Object]"><i _ngcontent-ulk-c11="" class="blm-icon-grid"></i></button>

I have tried below but not working.

document.getElementsByClassName("blm-icon-grid").parentElement
j08691
  • 204,283
  • 31
  • 260
  • 272
Santhosh
  • 1,053
  • 1
  • 20
  • 45

2 Answers2

0

Right way to use getElementsByClassName() is passing position:

 document.getElementsByClassName("blm-icon-grid")[0]
Julyano Felipe
  • 288
  • 2
  • 22
0

Javascript

document.getElementsByClassName("blm-icon-grid")[0].parentElement

JQuery

$(".blm-icon-grid")[0].parentElement
Ermal
  • 441
  • 5
  • 19