<div id="app"> <div class="one sc-123 two" onclick="alert('ok')">1<div> <div class="one two" onclick="alert('error')">2<div> </div> <script> document.querySelector("#app > div[class*='sc-']").click() </script>