Focus on Collapse Div

Multi tool use
Multi tool use


Focus on Collapse Div



How can I focus the div of a bootstrap collapse using jquery. Here is my script:




<div class="tab-pane fade in active" id="home1">
<div id="treeMapCategory">
<h2 class="m-b-xxs">Defect Categories<span class="btn btn-primary btn-xs pull-right" id="defectCategories" data-toggle="collapse" data-target="#insightDefectCategories"><i class="fas fa-comments"></i> Add Insights</span></h2>
</div>
</div><br/>
<div class="collapse" id="insightDefectCategories" tabindex="1">
<div class="ibox-content box">
<div class="insightsTitle"><br/>
<h3> <i class="fas fa-comments"></i> Insights for Defect Categories</h3>
</div>
</div>
</div>





Possible duplicate of change focus into particular div
– DragonBorn
Jul 2 at 7:36





I tried that but I think it cannot focus on that div because it is hidden I think
– Dranier
Jul 2 at 8:06




1 Answer
1



Is this what you want?




$("#insightDefectCategories").first().focus()


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<div class="tab-pane fade in active" id="home1">
<div id="treeMapCategory">
<h2 class="m-b-xxs">Defect Categories<span class="btn btn-primary btn-xs pull-right" id="defectCategories" data-toggle="collapse" data-target="#insightDefectCategories"><i class="fas fa-comments"></i> Add Insights</span></h2>
</div>
</div><br/>
<div class="collapse" id="insightDefectCategories" tabindex="1">
<div class="ibox-content box">
<div class="insightsTitle"><br/>
<h3> <i class="fas fa-comments"></i> Insights for Defect Categories</h3>
</div>
</div>
</div>





I want it to be focused on if I press the button
– Dranier
Jul 2 at 8:02






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

9tHGGKF8zWre
O9Z 1DL4POOrqG ikIaGR

Popular posts from this blog

Rothschild family

Cinema of Italy