JSFiddle - React, Tailwind, and code Playground
HTML
<div id="1foo"></div>
<button onclick="alert($('#foo').length);">
How many '#foo's are there?
</button>
JavaScript
var winId = 1;
$.fn.extend({
initCore: $.fn.init,
init: function (selector, context, rootjQuery) {
selector = selector.replace('#', '#' + winId);
return $.fn.initCore(selector, context, rootjQuery);
}
});
$.fn.init.prototype = $.fn;