Home > front end >  Front end use select2, how to obtain the value of the option value?
Front end use select2, how to obtain the value of the option value?

Time:03-24

The code is as follows:
 & lt; Select id="mySelect" style="width: 120 px;"> 




The option value is in the spring tag dynamically generated, page rendering is finished, I want to get the select of the selected option value, and then back to the background, but for select2 tags are not familiar with, look up the git usage, didn't also introduces this kind of how to use,
The page is like this:


Take less than the value in the console, why?

CodePudding user response:

 
$(' # select '). Val ();
$(' # select '). Select2 (' data ');
$(' # select '). Select2 (" val ");


You don't know how make of, anyway I looked on the website, these methods are good,

Did you use the iframe? Again top page must do not achieve the inside of the iframe interior with select select ah,,,

CodePudding user response:

Put the form form inside, just like normal controls, the actual submission or select values, select2 UI changes will change the value of the select

It's important to note that add the name to input control, or the value of the form is submitted without the name of the control will not submit to the server