想做一个如下图添加标签的功能

我用 bootstrap 做好 popover 之后, 点击按钮, 是直接通过 jQuery 塞进一段 html 实现了弹出下图所示窗口,
但是, jQuery 选择器死活不能获取弹出窗口的按钮和其它元素, 用了$(document).ready 也不行...

JS 代码:
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#addTags').popover({
html : true,
title: function() {
return $("#popover-head").html();
},
content: function() {
return $("#popover-content").html();
}
});
$('#addTags').click(function (e) {
e.stopPropagation();
});
$(document).click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('#addTags').popover('hide');
}
});
});
</script>
求大神帮忙看看, 谢谢!
PS:一直做后端, 也可能思路不对, 有更好的想法也希望分享一下.