欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Javascript實(shí)現(xiàn)一個(gè)簡單的輸入關(guān)鍵字添加標(biāo)簽效果實(shí)例

 更新時(shí)間:2017年06月01日 11:07:53   作者:itpinpai  
這篇文章主要給大家介紹了利用Javascript實(shí)現(xiàn)一個(gè)簡單的輸入關(guān)鍵字添加標(biāo)簽效果的相關(guān)資料,類似動(dòng)態(tài)添加標(biāo)簽的效果,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考借鑒,下面來一起看看吧。

本文主要給大家介紹的是關(guān)于js輸入關(guān)鍵字添加標(biāo)簽效果的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面來看看詳細(xì)的介紹:

實(shí)現(xiàn)功能:

  • 輸入關(guān)鍵字加空格鍵添加tag標(biāo)簽
  • 按Backspace鍵刪除一個(gè)標(biāo)簽
  • 輸入關(guān)鍵字后,鼠標(biāo)失去焦點(diǎn)添加tag標(biāo)簽
  • keyWord.init方法初始化方法

展示效果:

demo演示地址

示例代碼

<style>
 .block {
 display:flex;
 flex-direction:row;
 align-items:center;
 width:500px;
 height:30px;
 border:1px solid #ddd;
 padding:10px;
 margin:100px auto 0;
 }
 #wordTags {
 display:flex;
 flex-wrap:nowrap;
 }
 input{
 width:100%;
 height:20px;
 border:none;
 }
</style>

<div class="block">
 <div id="wordTags"></div>
 <input id="wordInput" type="text" name="" placeholder="請(qǐng)輸入關(guān)鍵詞以空格結(jié)尾">
 <input id="wordHiddenInput" type="hidden" name="">
</div>

<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
<script type="text/javascript" src="aspect.js"></script>
<script type="text/javascript" src="keyWord.js"></script>
$(function () {
 var keyWord = $("#wordInput").keyWord({
 panel: '#wordTags',
 value: '#wordHiddenInput',
 max: 3,
 tips: '最多只能輸入3項(xiàng)'
 });

 keyWord.init('php,java,前端開發(fā)')
});

屬性說明:

  • panel:面板的id
  • value:隱藏字段的id
  • max:最多輸入關(guān)鍵字個(gè)數(shù)
  • tips:提示語

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對(duì)腳本之家的支持。

相關(guān)文章

最新評(píng)論