Created
February 26, 2009 02:47
-
-
Save kindy/70606 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//调用idIncrement(“quizForm.quiz.questions[0].options[0].textContent” , "questions")的时候返回 | |
// quizForm.quiz.questions[1].options[0].textContent | |
//调用idIncrement(“quizForm.quiz.questions[0].options[0].textContent” , "options")的时候返回 | |
// quizForm.quiz.questions[0].options[1].textContent | |
function idIncrement(s,p){ | |
return s.replace(new RegExp('(' + p + '\\[)(\\d+)\\]'), function($a,$1,$2){ | |
return $1 + ((parseInt($2, 10) || 0) + 1) + ']'; | |
}); | |
} | |
idIncrement('quizForm.quiz.questions[0].options[0].textContent','questions'); | |
idIncrement('quizForm.quiz.questions[0].options[0].textContent','options'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment