Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript getElementsByClassName() to modify the Label Text

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #207719
    Kevin Mamaqi
    Participant

    Hello,

    I’m trying to figure out how to modify a label text using JavScript. The label has a class name, which I’m using to get it and modify, but no success yet. This is the code that I’m using: http://codepen.io/kevinmamaqi/pen/MawjYL

    Any idea on how to make it work?

    #207755
    Kevin Mamaqi
    Participant

    Well, I came up with this, which I don’t know if it is the best solution but it works:

    <script>
    var selectFunction = function() {
    
        document.getElementsByClassName('cat-item cat-item-19')[0].getElementsByTagName("label")[0].innerHTML = '<input type="checkbox" name="oftipodevideo[]" value="19"> Live';
    
        document.getElementsByClassName('cat-item cat-item-20')[0].getElementsByTagName("label")[0].innerHTML = '<input type="checkbox" name="oftipodevideo[]" value="20"> Official';
    
    };
    
    selectFunction();
    </script>
    

    Thanks for your help.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.