In jsp, jq gets the id value of the currently clicked select

 

 

 

Because the foreach of jstl is used, the id value of each select is different. If you want to get the id value of the currently clicked select in the change method, you need to pay attention to the following:

1. The syntax when getting the id must be correct, otherwise it is undefined. When using the firefox debugging tool, you can see the error message is undefined

This is the correct spelling

This is a wrong way of writing, this id is a variable, so naturally it is undefined

 

2. Set the class for select to distinguish between different types of select

 

3. Because it is the foreach traversal of jsp, you can only get the id of the first select to get a single select, so you need to use the this keyword to get the id of the current select, you can get the id corresponding to different selects

                    console.log($( this ).attr("id" ));
                     // console.log($("select[class='CENSOR']").attr("id")); this is also wrong, Because only the first value can be obtained in this way

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325259322&siteId=291194637