get class name from element with onclick

后端 未结 7 1916
我在风中等你
我在风中等你 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:40
    onclick="javascript:someFunction(this)"
    
    function someFunction(obj) {  
                console.log($(obj).attr('class'));  
    }
    

    You will get the two classes in the order of writing.

    0 讨论(0)
提交回复
热议问题