简体   繁体   English

使用Bootstrap如何显示带有关闭按钮的输入中的div列表中的选定div

[英]Using Bootstrap how to display selected divs from a list of divs in input with close button

Could you please check the link and help me for below mentioned criteria: 您能否检查链接并为我提供以下提及的条件:

On above link if I click on DOCUMENT TAB then it will be disappear from its panel and will appear in Search Input Box with a close button, so that if I click the CLOSE BUTTON then again it will disappear and will appear in its own panel again. 在上面的链接上,如果单击“文档”选项卡,它将从其面板中消失,并显示在带有关闭按钮的“搜索输入框”中,因此,如果我单击“关闭”按钮,它将再次消失并再次出现在其自己的面板中。

I have used Bootstrap. 我用过Bootstrap。

<div class="container-fluid">
<div id="gstContainer" style="margin:20px auto 20px auto;">

<div class="well well-lg" id="search-facet-container">
<div class="row">


<div class="col-sm-9 col-md-9 col-lg-9">
    <form class="form-horizontal" role="form">
    <span class="form-horizontal"><input type="text" class="form-control" id="searchinput"></span>        
    </form>
</div>


</div> 

<div id="facet" class="row" style="margin:20px auto;">
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Documents</a></div>
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Collaboration</a></div>
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Intranet & Web</a></div>
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Contact & Knowledge</a></div>
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Media</a></div>
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Products</a></div>
     <div style="margin: 0px 2px 2px 0px; float: left;"><a class="btn btn-primary">Sales & Marketing</a></div>

 </div>
</div>

Jsfiddle 的jsfiddle

My fiddle basically adds text to the input box on click of one of your buttons. 我的小提琴基本上是通过单击您的按钮之一将文本添加到输入框的。 There is so much more you could do with it. 您可以做更多的事情。

In my humble opinion, putting the buttons in the input box doesn't sound possible (I might be wrong) but if you change that input box to a div then your links/buttons can be sent there on click but nevertheless if you want to achieve something like that: you can either clone the button/link then append it's clone to the div if you decide to go with the div idea. 以我的拙见,将按钮放在输入框中似乎是不可能的(我可能是错的),但是如果将输入框更改为div,则可以在单击时将链接/按钮发送到此处,但是如果您愿意,实现类似的效果:您可以克隆按钮/链接,然后将其克隆附加到div(如果您决定使用div创意)。

 $('body').on('click', '.tosearch', function(e) {


     var clone = $(this).clone();//this is how the clone should work.
     $(this).find("a").addClass("selected");

     $('#searchinput').val($('#searchinput').val() + " " +$(this).attr("value"));

 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM