How do I select an element with special characters in the ID?

前端 未结 2 1069
野趣味
野趣味 2020-12-10 22:05

I have a page with a grid containing a lot if input with \"strange names\" to simulate an array:

 

        
2条回答
  •  無奈伤痛
    2020-12-10 22:34

    You need to escape the [, ], @ and . characters in the id selector. To do that, use \\ like this:

    var val = $('#Punteggi\\[\\@counter\\]\\.Descrizione').val();
    
    console.log(val);
    
    

提交回复
热议问题