1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Jquery Check Radio - Pls Help

Discussion in 'HTML & JavaScript' started by Moobs, Mar 4, 2015.

  1. Moobs

    Moobs Regular Member

    Joined:
    Jan 30, 2015
    Messages:
    238
    Likes Received:
    14
    I'm trying to make it so when a certain element is clicked this jquery script selects a specific radio. (should function the same as clicking the actual button)

    #id is the id of the input just to be clear. I changed it to #id for this example.


    Code:
    <input type="radio" class="input-radio " value="cow" name="moo" id="id" />
    
    
    
    $( ".selectionWrapper" ).click(function() {   
               $("#id").prop('checked', true);
                     
    });
     
  2. Moobs

    Moobs Regular Member

    Joined:
    Jan 30, 2015
    Messages:
    238
    Likes Received:
    14
    Solved

    Code:
    $("input[name=name][value='value']").prop("checked",true);	
     
  3. Darkhodge

    Darkhodge Newbie

    Joined:
    Feb 27, 2015
    Messages:
    15
    Likes Received:
    3
    Occupation:
    Web Developer
    Location:
    Surrey, UK
    Glad to hear you fixed it!

    Do you mind showing me the HTML (including the .selectionWrapper) in case there's a better way? For example, is it not possible to use a <label> in your particular case?