如何通過使用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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章