[英]How can I Append the Id attribute Selector or Store the Id in Jquery variable and use that variable as selector?
[英]How can I use the attribute selector with a variable?
我需要使用此表單,因為它可以處理元素ID中的空格。
$("div[id='content Module']").whatever();
但是我需要將“內容模塊”替換為變量嗎?
我試過了
$("div[id=" + my_var + "']").whatever();
但這沒有用
您缺少“
$("div[id=" + my_var + "']").whatever();
應該
$("div[id='" + my_var + "']").whatever();
試試這個$("div[id='" + my_var + "']").whatever();
你忘記了開放的使徒
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.