ID/Class Selector

前端 未结 5 940
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 20:32

I have some kind of problem with jQuery selectors.

Let\'s say i want to select $(\'#elementID\') but the elementID is a variable.

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-14 21:04

    Not sure what you mean, but:

    var variable = '#' + elementID;
    
    $(variable)...
    

提交回复
热议问题