如何通过使用ID的变量在jQuery中选择元素? - How do I select an element in jQuery by using a variable for the ID?

问题:

For example, the following selects a division with id="2": 例如,以下选择id =“2”的除法:

row = $("body").find("#2");

How do I do something like this: 我该怎么做这样的事情:

row_id = 5;
row = $("body").find(row_id);

The above syntax produces an error. 上述语法会产生错误。 I checked the jQuery documentation and answers here without success. 我检查了jQuery文档和答案,但没有成功。


解决方案:

参考: https://stackoom.com/en/question/37Xu
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章