我有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