Reputation: 613
I am using twitter bootstrap . I want to focus textbox in two ways:
these two cases are not working.
CSS: bootstrap-3.0.0
HTML:
<div class='container'>
<div class="checkbox">
<label>
<input type="checkbox" value="" />option1
</label>
</div>
<div class='checkbox'>
<label>
<input type="checkbox" value="" />
<form role="form">
<div class="row">
<div class="col-xs-2">
<input type="text" class="form-control" placeholder="Specify" />
</div>
</div>
</form>
</label>
</div>
</div>
Upvotes: 0
Views: 715
Reputation: 1889
IF you can add jquery here it is:
$(document).ready(function(){
$("#check_1").on("change",function(){
if($(this).is(":checked"))
{
$("#text_1").focus();
}
});
});
And your HTML
: (added id
attribute)
<div class='container'>
<div class="checkbox">
<label>
<input type="checkbox" value="" />option1
</label>
</div>
<div class='checkbox'>
<label>
<input type="checkbox" value="" id="check_1" />
<form role="form">
<div class="row">
<div class="col-xs-2">
<input type="text" class="form-control" placeholder="Specify" id="text_1" />
</div>
</div>
</form>
</label>
</div>
</div>
Updated Fiddle: http://jsfiddle.net/Wr6tH/13/
Upvotes: 2