Search code examples
greasemonkeytampermonkey

Greasemonkey - change HTML classname


i have a page with multi-div class like this:

<div class="fl wid470 adm-leftsection">

how can i change all to:

<div class="fl wid980">

Thanks!


Solution

  • Use document.querySelectorAll. This allows you to select DOM elements with specific attributes/classes.

    var selected=document.querySelectorAll(".fl.wid470.adm-leftsection");
    for(var i = 0, max = selected.length; i < max; i++) {
        all[i].className="fl wid980";
    }