I know this is a basic question. I have the following structure:
I am trying to scroll to their positions when clicking certain elements. The function that scrolls is as follows:
var target = ...
scrollTop: $('#' + target).offset().top
This is working fine with the ID "example", but not with the other universal IDs containing URIs:
jquery-2.2.0.min.js:2 Uncaught Error: Syntax error, unrecognized expression: #example.org/element1
jquery-2.2.0.min.js:2 Uncaught Error: Syntax error, unrecognized expression: #http://example.org/element2
I have been researching and tried options such as escaping characters and others, but nothing worked. Is there a way I can use internally such IDs?