use event.target to get the class value?

后端 未结 5 1292
你的背包
你的背包 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条回答
  •  Happy的楠姐
    2021-02-02 18:20

    Here you go.

    $("div").each(function (index, domEle) {
        if (domEle.hasClass("tag")) {
            console.log('yes');
        } else {
            console.log('no');
        }
    });
    

提交回复
热议问题