How Do I Get Javascript To Run More Than Once?
EDIT: here is a jsfiddle with all the code. https://jsfiddle.net/ypbd3fgf/2/ I'm using this simple code to add a class to a parent element in order to make the text on a selected r
Solution 1:
Edit:
The new code switches to the function(){...} format and looks for a click event on an input element then checks if its a radio button and that the parent is .row then it adds the bold and ez-selected classes to the radio button and removes them from other radios.
$("input").click(function() {
    if($(this).attr('type') == 'radio' && $(this).parents('.row').length > 0){
        $("input").closest('.row').removeClass('bold ez-selected');
        $(this).addClass('bold ez-selected');
     }
})
Solution 2:
your code should look somewhat like this:
<script type="text/javascript"> 
    $(function() {
        $("input[type='radio']").click(function(e) {
            var targ = e.target
            $("div[class='row'][class='bold']).removeClass('bold');
            $(targ).parents('div[class="row"]').addClass('bold');
        })
        $(".ez-selected").closest('.row').addClass("bold");
    }); 
</script>
Post a Comment for "How Do I Get Javascript To Run More Than Once?"