I have a website created on bootstrap. What I'm trying to do is I want to auto-select the input field inside the modal.
SCRIPT
function click_qty_edit(){ $('#modal_edit_qty_2').modal('show'); /* I have tried this on JavaScript but nothings work :( */ var input_auto = document.getElementById('edit_2_qty'); input_auto.focus(); input_auto.select(); /* Then, I've tried also on jQuery and nothing happens again :( */ $('#edit_2_qty').focus().select(); } HTML MODAL
<div id="modal_edit_qty_2" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="classInfo" aria-hidden="true"> <div class="modal-dialog modal-lg" style="width:350px;"> <div class="modal-content"> <div class="modal-header"> <div> <span class="text-primary">Enter New Quantity</span> </div> <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="outline:none;"> × </button> </div> <div class="modal-body"> <div class="row"> <div class="col-md-12"> <input type="number" id="edit_2_qty" style="width:100%;text-align:center;border:1px #9124A3 solid;padding:10px;border-radius:8px;"> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" onclick="save_edit_qty_2()">Save</button> </div> </div> </div> </div> Can anyone explain to me what was the possible problem with this function? or is there any way to do this? Thanks in advance :)