Javascript/jQuery - How do I obtain name of the class of clicked element?

前端 未结 6 1559
礼貌的吻别
礼貌的吻别 2020-12-16 00:27

I googled and googled and I concluded that it\'s very hard to get answer on my own.

I am trying to use jquery or JavaScript to get a property of clicked element. I c

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 01:17

    There's a way to do this without coding. Just open the console of your browser (f12?) and go to element you want. After that, hover or click the item you want to track.

    Every change done on the DOM will be for a few seconds marked (or lightened) as another color on the console. (Watch the screen capture)

    On the example, each time I hover a "colorItem", the 'div' parent and the "colorItem" class appears lightened. So in this case the clicked class will be 'swiper-model-watch' or 'swiper-container' (class of the lightened div)

提交回复
热议问题