javascript - ".check" for radio in JS -


here's code:

document.getelementbyid("frequencyweekly").checked = function() {     document.getelementbyid("newsoptions").classname = "activesubscription"; };      <div id="newsoptions">         <input type="radio" id="frequencyweekly" name="newsletterfrequency">         <label for="frequencyweekly">weekly</label>          <input type="radio" id="frequencymonthly" name="newsletterfrequency">         <label for="frequencymonthly">monthly</label>     </div> 

i .newsoptions div have class .activesubscription if #frequencyweekly button checked. how should that?

checked boolean, not event fires function, want

if ( document.getelementbyid("frequencyweekly").checked ) {     document.getelementbyid("newsoptions").classname = "activesubscription"; } 

if want in event handler be

var box  = document.getelementbyid("frequencyweekly"),     elem = document.getelementbyid("newsoptions");  box.addeventlistener('change', function() {     if ( this.checked ) {         elem.classlist.add("activesubscription");     } else {         elem.classlist.remove("activesubscription");     } }, false); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -