input - Use Javascript to apply CSS property of fontWeight to label tag of radio button -


i have searched internet looking solution, , i've reached wit's end. i've been experimenting javascript few weeks now, life of me can't manage make new project work.

my initial goal bold correct answers online quiz i've been developing 1 of classes. can bold correct answers using css enough, marked class name of "correct", can't make javascript execute command same @ click of button.

if me solve issue appreciated. clearcorrectanswers() function meant reverse effects of showcorrectanswers().

the javascript i've been developing can found below:

function showcorrectanswers() {     var correctanswers = document.getelementsbyclassname("correct");      (var count = 0; count < correctanswers.length; count++) {         correctanswers[count].style.fontweight = "bold";     } }  function clearcorrectanswers() {     var correctanswers = document.getelementbyclassname("correct");      (var count = 0; count < correctanswers.length; count++) {         correctanswers[count].style.fontweight = "normal";     } } 

the html can likewise found below:

<input type="submit" value="submit test" onclick="computegrade()"> <button type="button" onclick="showcorrectanswers()">show correct answer</button> <button type="button" onclick="clearcorrectanswers">clear correct answer</button> <p>1. external behavior of system described _____.     <br>     <input type="radio" id="1" name="as1" value="1">     <label class="correct">a. functional models</label>     <br>     <input type="radio" id="2" name="as1" value="0">     <label>b. structural models</label>     <br>     <input type="radio" id="3" name="as1" value="0">     <label>c. behavioral models</label>     <br>     <input type="radio" id="4" name="as1" value="0">     <label>d. interaction diagrams</label>     <br>     <input type="radio" id="5" name="as1" value="0">     <label>e. statechart diagrams</label> </p> <p>2. analyst depicts static view of information system _____.     <br>     <input type="radio" name="as2" value="0">     <label>         <label>a. use-case models</label>         <br>         <input type="radio" name="as2" value="1">         <label class="correct">b. structural models</label>         <br>         <input type="radio" name="as2" value="0">         <label>c. behavioral models</label>         <br>         <input type="radio" name="as2" value="0">         <label>d. interaction diagrams</label>         <br>         <input type="radio" name="as2" value="0">         <label>e. statechart diagrams</label> </p> <p>3. 2 types of interaction diagrams ______________ diagrams.     <br>     <input type="radio" name="as3" value="0">     <label>a. use-case , sequence</label>     <br>     <input type="radio" name="as3" value="0">     <label>b. class , sequence</label>     <br>     <input type="radio" name="as3" value="1">     <label class="correct">c. sequence , communication</label>     <br>     <input type="radio" name="as3" value="0">     <label>d. object , communication</label>     <br>     <input type="radio" name="as3" value="0">     <label>e. statechart , object</label> </p> 

<script> function showcorrectanswers() {     var correctanswers = document.getelementsbyclassname("correct");      (var count = 0; count < correctanswers.length; count++) {         correctanswers[count].style.fontweight = "bold";     } }  function clearcorrectanswers() {      var correctanswers = document.getelementsbyclassname("correct");      (var count = 0; count < correctanswers.length; count++) {         correctanswers[count].style.fontweight = "normal";     } } </script> 

and html :

<input type="submit" value="submit test" onclick="computegrade()"> <button type="button" onclick="showcorrectanswers()">show correct answer</button> <button type="button" onclick="clearcorrectanswers()">clear correct answer</button>  <p>1. external behavior of system described _____.<br>     <input type="radio" id="1" name="as1" value="1"><label class="correct"> a. functional models</label><br>     <input type="radio" id="2" name="as1" value="0"><label> b. structural models</label><br>     <input type="radio" id="3" name="as1" value="0"><label> c. behavioral models</label><br>     <input type="radio" id="4" name="as1" value="0"><label> d. interaction diagrams</label><br>     <input type="radio" id="5" name="as1" value="0"><label> e. statechart diagrams</label> </p>   <p>2. analyst depicts static view of information system _____.<br>     <input type="radio" name="as2" value="0"><label><label> a. use-case models</label><br>         <input type="radio" name="as2" value="1"><label class="correct"> b. structural models</label><br>         <input type="radio" name="as2" value="0"><label> c. behavioral models</label><br>         <input type="radio" name="as2" value="0"><label> d. interaction diagrams</label><br>         <input type="radio" name="as2" value="0"><label> e. statechart diagrams</label> </p>  <p>3. 2 types of interaction diagrams ______________ diagrams.<br>     <input type="radio" name="as3" value="0"><label> a. use-case , sequence</label><br>     <input type="radio" name="as3" value="0"><label> b. class , sequence</label><br>     <input type="radio" name="as3" value="1"><label class="correct"> c. sequence , communication</label><br>     <input type="radio" name="as3" value="0"><label> d. object , communication</label><br>     <input type="radio" name="as3" value="0"><label> e. statechart , object</label> </p> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -