Access to an element with an identifier containing "." character

I am trying to access elements using jquery method $('#elementID'). If any element contains the character "." , eg

id="element.0" 
id="element.1"

I cannot access this item.

This is because of the "." in line id?

+3
source share
2 answers

You need to avoid the point with \\

$('element\\.0');

http://api.jquery.com/category/selectors/

+5
source

It will look like this:

$("#element\\.0")

, ( @patrick , ), , -, id="element-0"..., / ( .).

+7

Source: https://habr.com/ru/post/1761094/


All Articles