Home >Web Front-end >CSS Tutorial >How to get decimal point label in css selector

How to get decimal point label in css selector

小云云
小云云Original
2018-03-28 10:54:152101browse

因为项目中章节配置的时候有小数点,1,1.1,1.2,1.11的标题,这个时候每一行标题的id,class设置成标题号是独一无二的标记。但是,直接用js获取是获取不到的,例如$('#3.22')打印只能获取到document.

解决方案


var array = id.split('.');
var id = '';
for(var i=0;i<array.length;i++){
   if(i == array.length-1){
      id += array[i];
   }else{
      id += array[i]+&#39;\\.&#39;;
   }
}

就是将.用\转义输出了。下面再用$('#id')就可以获取到标签了。

相关推荐:

Javascript中使用A标签获取当前目录的绝对路径方法_javascript技巧

The above is the detailed content of How to get decimal point label in css selector. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn