Jquery deselect select drop-down box sample code

Source: Internet
Author: User

Jquery deselect select drop-down box sample code

This article mainly introduces the sample code of jquery's unselect select drop-down box. If you need it, you can refer to it and hope to help you.

There are three select drop-down boxes

Two classes are hidden in one category. When selecting a category, the category is displayed and the items selected by other classes are cleared.

This requirement is a bit ..........

 

The following are three select statements:

 

The Code is as follows:

<Select name = "pWaqqqy" id = "sel_type" onchange = "selectFunction ()">

<Option value = ""> all </option>

<Option value = "7"> aa </option>

<Option value = "8"> bb </option>

</Select>

<Select name = "pWay" id = "sel_children0" style = "display: none;">

<Option value = ""> all </option>

<Option value = "5"> a </option>

<Option value = "3"> a </option>

<Option value = "1"> a </option>

<Option value = "2"> a </option>

<Option value = "6"> a </option>

</Select>

<Select name = "pWay" id = "sel_children1" style = "display: none;">

<Option value = ""> all </option>

<Option value = "4"> B </option>

</Select>

 

Jquery extension. When calling, use $ ("select"). removeSelected ();

The Code is as follows:

JQuery. fn. removeSelected = function (){

This. val ("");

};

 

To select a Category Selection box, call the selectFunction () method:

The Code is as follows:

Function selectFunction (){

If ($ ("# sel_type"). val () = "7 "){

$ ("# Sel_children0"). show ();

$ ("# Sel_children1"). hide ();

$ ("# Sel_children1"). removeSelected ();

} Else if ($ ("# sel_type"). val () = "8 "){

$ ("# Sel_children1"). show ();

$ ("# Sel_children0"). hide ();

$ ("# Sel_children0"). removeSelected ();

} Else {

$ ("# Sel_children0"). hide (). removeSelected ();

$ ("# Sel_children1"). hide (). removeSelected ();

}

}

 

The premise is to first introduce the jquery. js File

 

Related Article

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.