Home>
Is there any way to access HTML elements with IDs including symbols such as slashes as shown below?
ABC
console.log ($("# point-abc \/company"));
Error
Uncaught Error: Syntax error, unrecognized expression
-
Answer # 1
-
Answer # 2
It's strange to write "slash" and if you need to escape "backslash"
It will be a good way of writingABC
"\" Becomes "\\" for string notation, and it escapes it, so it is "\\\\"
In addition, "/" becomes "\ /", so escape and "\\ /" need 6 "\" results
Use escape functionconsole.log ($("#" + CSS.escape ("point-abc \\/company")). length);
Related articles
- javascript - convert elements (numbers) divided in an array from strings to numbers
- javascript - i want to access the graphql endpoint launched with rails from the front
- javascript - i want to conditional branch html tag elements in react, jsx
- javascript - i want to count the number contained in the elements of an array
- i want to raise the same event for multiple elements with javascript, but the event does not occur (modal window example)
- i want to check the elements of a multidimensional array with javascript
- [javascript] i want to show/hide elements on the browser
- javascript - dynamically added elements are called multiple times
- regarding getting javascript elements
- [javascript/jquery] how to describe selector access
- javascript - i want to remove the unwilling overlap of elements
- javascript - in swiperjs, i want to brighten elements and switch slides without moving the slides
- javascript - i want to access the api from google app script
- (javascript) i want to extract all the elements based on the value of a specific element in the array
- javascript - show only selected elements → select again to make the selected element at the bottom → show the remaining items at
- javascript - i want the script to run when i access a specific url in gas
- i want to increase the number of html class elements in order using javascript
- javascript - [heroku] you will not be able to access the uploaded image after a certain period of time
- i want to extract only the elements that match the specified elements of the map array in the elements of the javascript array
- javascript i want to repeat the duplication of elements with the same event processing
Related questions
- javascript : How to copy its contents when you click on a button?
- javascript : Handle clicking on a part of a parent element that has no child blocks
- Get data using JavaScript
- javascript : Active menu item with submenu expansion
- javascript : Hash in SHA512 without haemorrhoids in jQuery
- javascript : Error in asung js function
- javascript : How to make a slider like this on Slick?
- javascript : Question about Yandex Maps
- javascript : Add second jQuery modal window
- javascript : Saving a file in Windows-1251 encoding
console.log ($("# point-abc \\\/company"));