javascript setattribute to multiple element

后端 未结 3 1042
梦毁少年i
梦毁少年i 2020-12-05 11:31

I have many div with the class publish_0 that I would like to change to publish_1 on click of a button.

Right now I use this but it only ch

3条回答
  •  一整个雨季
    2020-12-05 12:09

    You can use this with jquery:

    $(".publish_0").attr("class", "publish_1")
    

    Alternatively, use getElementsByClassName and loop through the DOM elements returned.

提交回复
热议问题