Android CSS Set select height bug resolution and JQ action Select

Source: Internet
Author: User

Using CSS to set the height and line-height of select is invalid in some versions of Android, but can be added by adding "-webkit-appearance:listbox;" property to resolve the bug, the full instance code is as follows:

. styled-select {
-webkit-appearance:listbox;
width:100%;
font-size:36px;
display:inline-block;< c4/> height:80px;
line-height:80px;
Text-align:center;
Background: #8f7a66;
margin-top:40px;
Color: #f9f6f2;
border-radius:3px;
Text-decoration:none;
}



jquery operation Select (value, set selected)


Every time you work on a SELECT, you always have to come out and flip the data, so you can summarize it, and then turn here.

such as <select class= "selector" ></select>

1, set value to Pxx item selected

$ (". Selector"). Val (" Pxx ");

2, setting text to Pxx selects

$ (". Selector"). Find ("option[text= ' Pxx ')"). attr ("selected", true);

Here is a use of brackets, preceded by an equal sign in brackets, without quotation marks. In many cases, the use of brackets can make logic simple.

3, gets the value

$ (". Selector") of the currently selected item. val ();

4, gets the text

$ (". Selector") of the currently selected item. Find ("option:selected"). Text ()

A colon is used here, and mastering its usage and extrapolate also makes the code concise.

often uses a cascade of SELECT, that is, the value of the second select changes with the value selected by the first select. This is very simple in jquery.

such as:

$ (". Selector1"). Change (function () {
//Empty the second
$ (". Selector2") first. empty ();
In practical applications, the option here is generally to generate multiple
var option = $ ("<option>") with Loops. val (1). Text ("Pxx");
$ (". Selector2"). Append (option);


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.