I am creating a web page that includes several HTML-templates that may contain IDs. As a result the final page may contain several HTML element with the exact same ID which
As long as you use jQuery context, e.g. $('#some-id', context), it will work fine.
$('#some-id', context)
But you should really use class names instead of IDs for elements that occur more than once in a page.