jQuery gets the select value

Updated on technology 2024-04-14
6 answers
  1. Anonymous users2024-02-07

    .each($("select"), function (i, n) { Iterate through all selects, how to write the traversal condition and then change it.

    Man. Female...insertafter($(this));

    this).remove();

    If you want to generate the corresponding number of li according to the value of the option, you can spell a string by yourself and add the $( on it"

  2. Anonymous users2024-02-06

    Gets the text of the selected item.

    var item = $("select[@name=items] option[@selected]").text();

    The second element of the select drop-down box is the currently selected value select id')[0].selectedindex = 1;

    #sel").attr("value",'-sel3');Set the item with value=-sel3 to the currently selected item.

  3. Anonymous users2024-02-05

    You haven't said if there are other options in the option? If so, do you keep it or how do you deal with it?

    Describe the problem clearly first, and then help you figure it out, otherwise the back and forth of the requirements is the most annoying.

  4. Anonymous users2024-02-04

    <>2. In the label, enter jquery**:.

    var a =

    'option[selected="1"]'each(function ()

    3. The browser runs the page, and the selected values are put into an array and printed.

  5. Anonymous users2024-02-03

    1. First of all, make sure that each option tag in select has a value attribute;

    2. How to write jquery.

    #sele').val() assumes that the id of select is sele, so that the value of the currently selected option can be obtained

    3. When there is no selection at the beginning, the default is the value of the first option;

    4. If you want to test, you can write a change event, that is, every choice will trigger $('#sele').change(function())5, if you want to set a certain one to be selected at the beginning of js, you can $('#sele').val('value'Write in parentheses the value of one of the options you want to select by default.

  6. Anonymous users2024-02-02

    1.If none of the option elements under the select element have a selected attribute specified, the first one is selected by default.

    2.You can get the index of the selected option element by .

    3.You can get the selected option element through .

    option element text3, you can get the value attribute value of the option element through value3; You can get the text inside the option element by , i.e. text3.

    4.If the option element does not have a value attribute defined, it cannot be obtained in IE, but safari, opera, and firefox can still be obtained through , and the value is the same as .

    5.You can use && to determine if the option element has a value property defined.

    6.Therefore, the script to get the current select element value is as follows:

    var getselectvalue = funtion(select)

    return null;}

Related questions
10 answers2024-04-14

Let's take a JSON example;

1. What are the benefits of using json, for example, your ** uses text, and you need to split and other processing after returning; >>>More

6 answers2024-04-14

You can give the same name to the select tag where class is sel, e.g. sel, with a window loading function in the script. >>>More

4 answers2024-04-14

Write to the topic.

14 answers2024-04-14

Since the release of jQuery, it has stopped the compatibility of IE versions (IE6, IE7, IE8). If you need to be compatible with an earlier version of Internet Explorer, we recommend that you use native JS or an earlier version. >>>More

3 answers2024-04-14

Here's how to get Wealth Value:

Know the value of wealth: >>>More