jquery operation input Select and radio selected

Source: Internet
Author: User

,Select:

<div class= "Form-group" >
<label for= "" class= "col-sm-3 Control-label" > Role type </label>
    < Div class= "col-sm-9" >
        <select id= "typeID" name= "Role_type" datatype= "*" >
        <option value= "1" > Public </option>
        <option value= "0" > Private </option>
        </select>
    </div>
</ Div>

Select the method:

$ ("#typeId"). Val (Data.type); /**/data.type the data returned for the backend needs to be aware that the value of the JSON property is the same as the value attribute in option, otherwise you cannot select the *

Radio:

<div class= "Form-group" >
    <label for= "" class= "col-sm-3 Control-label" > account status </label>
    < Div class= "col-sm-9" >
        <label class= "Radio-inline" >
            <input type= "Radio" name= "Status" value= "1" >
            effective
        </label>
        <label class= "Radio-inline" >
            <input type= "Radio" name= "status" Value= "0" >
            invalid
        </label>
    </div>
</div>

Select the method:

$ ("input[name=status][value=" + Data.status + "]"). attr ("Checked", true);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.