Camel case in HTML tag attributes and jquery - doesn't work, why?

后端 未结 2 502
死守一世寂寞
死守一世寂寞 2020-12-11 18:55

Yes, there are similar questions, but they are about jquery adding lowercase attributes like here: Does the attr() in jQuery force lowercase?

But I have a different

2条回答
  •  难免孤独
    2020-12-11 19:54

    Instead of using ".data()" you could just use ".attr()" to access the value of the attribute, then you could reference it by the name you've given it; like the following:

    $(element).attr('data-projectId');
    

提交回复
热议问题