开发者

How can I refer to the calling element in JQuery?

开发者 https://www.devze.com 2022-12-11 22:09 出处:网络
For example: <input type=\"text\" size=\"5\" id=\"question\'+$qid+开发者_StackOverflow\'\"onKeyUp=\"checkanswer(\'+i+\')\"/></div>

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消