Changing class of h2 inside specific div

Posted by user1985060 on Stack Overflow See other posts from Stack Overflow or by user1985060
Published on 2013-10-25T03:42:22Z Indexed on 2013/10/25 3:54 UTC
Read the original article Hit count: 103

I want to make it so that everytime you click on an 'h2' tag, the 'input' inside gets selected and the 'h2' tag changes background, but if another 'h2' tag is clicked, the current highlight and 'input' selection changes accordingly.

problem is that I have 3 different that do the same and with my code all the 3 forms are affected rather one. How do i limit my changes to only be contained to that form. Here is some code for clarification '

<form>
    ...
    <h2 onclick="document.getElementById(1001).checked='True'
    $('h2').removeClass('selected');
    $(this).addClass('selected');
    ">
    CONTENT
    <input type="radio" name="radio" id="1001" value="1001" />
    </h2>
    ...
 </form>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery