How can I refer to the calling element in JQuery?
For example:
<input type="text" size="5" id="question'+$qid+开发者_StackOverflow'"onKeyUp="checkanswer('+i+')"/></div>
I want to refer to the "question'+$qid+'"
element inside the function checkanswer(), how to do it?
Maybe I can do it by onKeyUp="checkanswer('+$qid+')"
, is there other elegant way to do it?
Not sure I fully understand what you're asking for, but if you're trying to pass the current item to checkanswer()
you can just do:
<input type="text" size="5" id="question'+$qid+'"onKeyUp="checkanswer(this)"/>
Assuming $qid and 'i' are the same number you could do $('#question' + param) in your checkanswer() function (where 'param' is the parameter that 'i' represents).
精彩评论