jQuery: dealing with a space in the id attribute

前端 未结 5 2142
失恋的感觉
失恋的感觉 2020-12-01 16:29

I have an element with id=\"A B\". The following code fails:




        
5条回答
  •  春和景丽
    2020-12-01 16:51

    As they mentioned you shouldn't use spaces in id. But anyway, wouldn't this be working for you?

    $("[id='A B']").click(...)
    

    EDIT: yes it works, tested it!!! Don't kill me, standard-lovers!! ;-P

提交回复
热议问题