我在bootsrap popover中创建一个登录表单。我无法在popover中的文本输入框中设置值。当我关闭并打开弹出框时,它将字段重置为空,但我想将输入的单词保留在框中,请指教。
演示: http://jsfiddle.net/D3VP9/4/
<a href="#" class="trigger" data-placement="bottom">Popover link II</a>
<div class="popover-markup">
<div class="head hide">Lorem Ipsum II</div>
<div class="content hide">
<form role="form">
<div class="form-group">
<label class="control-label">E-Mail</label>
<input class="form-control" id="username" placeholder="hello@example.com" type="text" />
</div>
<div class="form-group">
<label for="inputPassword" class="control-label">Passwort</label>
<input class="form-control" id="password" placeholder="******" type="password" />
</div>
<div class="form-group">
<button type="button" class="btn btn-primary btn-block">Login</button>
</div>
<div class="row">
<div class="col-xs-6 col-md-8">
<div class="checkbox">
<label>
<input id="vehicleChkBox" type="checkbox" /> Remember me
</label>
</div>
</div>
<div class="col-xs-6 col-md-4">
<button type="button" class="btn btn-link pull-right small" onClick="remember_me()">Register new Account</button>
</div>
</div>
</form>
</div>
<div class="footer hide">test</div>
</div>
脚本:
$(function() {
$('.trigger').popover({
html: true,
title: function () {
return $(this).parent().find('.head').html();
},
content: function () {
return $(this).parent().find('.content').html();
}
});
});