I have is a hidden div. When a link is clicked, the div
should be toggle with an input
field and a dropdown select
. How do I make this input field autofocus
as soon as the div slides down?
This is my HTML for hidden DIV
:
<div class="new-category-box">
<div class="form-group">
<input type="text" class="form-control" id="new_category" name="new_category" autofocus>
</div>
<div class="form-group">
<select class="form-control" name="parentCategoryList">
<option>-- Parent Category --</option>
<option value="">Lorem ipsum</option>
<option value="">Lorem ipsdffum</option>
</select>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Add New Category</button>
</div>
</div>
I went through this question. But now this DIV
not toggle.
This is my Jquery:
$( "a.add_new_category" ).click(function() {
$( ".new-category-box" ).slideToggle(function(){
$("#new_category").focus();
});
);
});
Can anybody tell me what is wrong this code?