How can I change HTML attribute names with jQuery?

后端 未结 7 1414
無奈伤痛
無奈伤痛 2020-11-30 06:51

I would like to change all the names of the attributes where class=\"testingCase\" throughout all my whole html document.

e.g. Change:

&         


        
7条回答
  •  庸人自扰
    2020-11-30 07:07

    same answer as @nickf but cleaner code:

    $('a.testingCase[title]').each(function() {
        var curElem = $(this);
        curElem.attr("newTitleName", curElem.attr('title')).removeAttr('title');
    });
    

提交回复
热议问题