get class name from element with onclick

后端 未结 7 1914
我在风中等你
我在风中等你 2020-12-10 08:01

Because of different reasons I can NOT use $(\'.class\').click or on(\'click\', function..)

So I really have to use the onclick=\"\" event from the html element.

7条回答
  •  执念已碎
    2020-12-10 08:21

    Add this as an argument to the inline event handler:

    CLICK HERE
    

    Then use the className property of element to get the className

    function someFunction(e,abc) {
          console.log(this);
          alert(e.className);
    }
    

    Working Example http://jsfiddle.net/Aw8Rb/8/

提交回复
热议问题