JSFiddle - React, Tailwind, and code Playground

HTML

<div id="abc!1">
This is a test
</div>
<div id="jqresult">
</div>
<div id="domresult">
</div>

JavaScript

var id = "abc!1";
$('#jqresult').html('jQuery matches: <b>' + ($(id).length > 0) + '</b>');
$('#domresult').html('getElementById matches: <b>' + (document.getElementById(id) != null) + '</b>');