我有HTML机身采用此按钮:关注输入字段时弹出窗口中显示(引导酥料饼)
<div tabindex="0" class="image-copy-to-clipboard image-copy-to-clipboard-icon" role="button" data-placement="bottom" data-toggle="popover" data-trigger="focus" data-container="body">
<div class="head hide">Press Ctrl+C to copy user info</div>
<div class="content hide">
<input id="userInfo" type="text" placeholder="" value="#{{user.Id}} : {{user.Name}}" autofocus="autofocus" />
</div>
</div>
而这个脚本,以它的工作原理:
$('[data-toggle="popover"]').popover({
html: true,
title: function() {
return $(this).parent().find('.head').html();
},
content: function() {
return $(this).parent().find('.content').html();
}
});
$('#userInfo').focus(function (event) {
var self = $(this);
setTimeout(function() {
self.select();
}, 100);
});
$(document).on('click', function(event) {
if (event.target.nodeName == 'HTML') {
$('.popover.fade').hide().remove();
}
});
当显示弹出窗口,我需要专注于输入字段并且必须选择所有文本。我尝试了很多问题,但没有正常工作。请帮我解决这个问题。
感谢所有,结果是https://jsfiddle.net/HUSTLIN/e9yqyas1/1/ – HUSTLIN