<div id="x1">A</div> <div id="x1">B</div> <div id="x2">C</div> <script> console.log($('[id="x1"]')); </script>