I'm creating a react js application, and using HTML select dropdown. I want to focus on select when page load. below shows which code I'm using in select.
<select id="sel_bookID" autofocus>
<option value="binary">
Binary Search
</option>
<option value="linear">
Linear Search
</option>
<option value="interpolation">
Interpolation Search
</option>
</select>
I'm also using below mention some StackOverflow solution but did not work.
//jquery
$(document).ready(function(){
$('#sel_bookID').focus();
});
or
//javascript
document.addEventListener('DOMContentLoaded', function(){
document.getElementById('sel_bookID').focus();
}, false);