jQuery,使用〜作为id的一部分 - 如何? [英] jQuery, use ~ as a part of id - how?
本文介绍了jQuery,使用〜作为id的一部分 - 如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我有一个表单,哪些元素使用某种约定命名,即它们是路径,其部分使用〜
符号分隔。
In my application I have a form, which elements are named using a certain convention, i.e. they are paths, the parts of which are separated using the ~
sign.
现在我需要通过id在jQuery中访问其中一个,但是我失败了。显然,jQuery将其视为 #prev~sibling
的事情。
Now I need to access one of them in jQuery by id, but I fail. Apparently, jQuery treats it as the #prev ~ sibling
thing.
我有没有办法逃避jQuery函数中的〜
符号?
Is there a way I can sort of escape the ~
sign in the jQuery function?
以下是我的代码的示例:
Here is an example of what my code looks like:
<select id="a~b~c">
<option value='1'>one</opiton>
</select>
<script>
$("#a~b~c").change(function(){
alert('a');
});
</script>
推荐答案
试试这个
$("#a\\~b\\~c").change(function(){
alert('a');
});
这篇关于jQuery,使用〜作为id的一部分 - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文