use event.target to get the class value?

后端 未结 5 1175
你的背包
你的背包 2021-02-02 18:13

i have a DOM element with class=\'tag\'.

i want to check if the class value is tag and alert a message if it\'s true.

i wrote:

    $(\"#thread\")         


        
5条回答
  •  后悔当初
    2021-02-02 18:27

    you are using jquery's each method incorrectly. it takes two arguments, neither one of them is an event (that would respond to the target property). from the docs:

    $.each([52, 97], function(index, value) { 
      alert(index + ': ' + value); 
    });
    

    See CMS's answer for the proper way of checking if elements have a given class name.

提交回复
热议问题