在html元素的id中插入点或句点的目的是什么

lin*_*ran 1 html javascript css jquery

我不知道在html元素的id中插入点或句点的目的是什么,我们在任何编码语言中都有任何额外的好处吗?

<div id="PAT.TID" class="lineHeight frmData">Headset,  e.g. Bluetooth headset,  for mobile device has configuration logic which configures headset based on sensor data indicating whether headset is being worn by user</div>
Run Code Online (Sandbox Code Playgroud)

我想选择id ="PAT.TID"的div,我该怎么做

document.querySelector('#PAT\.TID')
Run Code Online (Sandbox Code Playgroud)

这里我null在chrome浏览器控制台中有一个对象

我如何选择像使用纯javascript的id元素中包含的wildchar?(如querySelector)

Ry-*_*Ry- 7

在JavaScript中,字符串文字'#PAT\.TID'等同于'#PAT.TID'.你需要为JavaScript转义一次,对CSS一次:

document.querySelector('#PAT\\.TID')
Run Code Online (Sandbox Code Playgroud)

不,除了让生活对其他人感到悲惨之外,没有必要这样做.