Today, we need to use a select change event to obtain the months with configuration using ajax (just as there is a record ), and the configured month is returned in the form of a string, such as: 3, 4, 5, 6, and 7. The Code is as follows // change event of the year selector... SyntaxHighlighter. all (
Today, we need to use a select change event to obtain the months with configuration using ajax (just as there is a record ), the configured month is passed as a string, for example:
Returns in the form of 3, 4, 5, 6, and 7.
The Code is as follows:
// Change event of the year selector $ ("# year "). change (function () {for (var I = 1; I <= 12; I ++) {document. getElementById ("month" + I ). style. background = "# c0c0c0";} $. ajax ({type: "POST", data: {"yearSelect": $ (this ). val ()}, dataType: "TEXT", url: "<% = path %>/rewardList. do? Method = changeMonth ", success: function (result) {if (result. trim ()! = "") {Var monthed = result. split (","); for (var I = 0; I
There is no problem in the above Code, but if this sentence is changed to Javascript in dom mode, the dom object will never be obtained in the last month, and this dom object exists, the data is also completely normal.
That is, the following error occurs: document. getElementById (id). style. background = "orange ";
The preceding operations are normal.
Example:
When the data is 1, 2, 3, 5, 6
Month1, mon2, month3, and month5 can change the color normally. The last one, no matter what the number is, is always incorrect. The Firefox JS error console prompts:
Document. getElement (...) is null. That is to say, he does not get this object. JQUERY can be used.
But he actually exists .. So it's hard to understand ..