css選取器中小數點標籤擷取方法

來源:互聯網
上載者:User
因為項目中章節配置的時候有小數點,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]+'\\.';   }}

就是將.用\轉義輸出了。下面再用$('#id')就可以擷取到標籤了。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.