current position:Home>JQuery operation select (value, setting, selected)

JQuery operation select (value, setting, selected)

2021-08-22 05:30:24 mb611f1a641bd18

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

1、 Set up value by pxx Check the item of


2、 Set up text by pxx Check the item of


    Here is a usage of brackets , The equal sign in square brackets is preceded by the attribute name , No quotes . A lot of times , The use of brackets can make logic very simple .

3、 Gets the... Of the currently selected item value


4、 Gets the... Of the currently selected item text


    The colon is used here , Mastering its usage will also make the code concise .


It is often used select Cascade of , That is, the second select With the first select Selected value changes . This is in jquery Is very simple .

Such as :$(".selector1").change(function(){

     // First empty the second


     // In practical application , there option Generally, multiple are generated by loops

      var option = $("<option>").val(1).text("pxx");



copyright notice
author[mb611f1a641bd18],Please bring the original link to reprint, thank you.

Random recommended