"input"
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html lang='en' class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/ravid7000/pen/GqyOvX?limit=all&page=3&q=tag" /> <link href="https://fonts.googleapis.com/css?family=Raleway:300,400" rel="stylesheet"> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'><link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css'> <style class="cp-pen-styles">body { padding: 0; margin: 0; font-family: 'Raleway', sans-serif; background: #e9e9e9; } #app { padding: 20px; width: 600px; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 40px 50px rgba(0, 0, 0, 0.25); outline: none; font-size: 1em; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); position: absolute; } #app input { outline: none; width: auto; border: 0; float: left; padding: 8px; background: none; } #app::before { content: ''; display: table; } #app::after { content: ''; display: table; clear: both; } .tag { border-radius: 3px; background: #b5aff9; float: left; margin: 3px; padding: 4px; font-size: 1em; vertical-align: middle; box-shadow: 0px 1px 4px #c6c6c6, 0px 2px 17px #d1d1d1; } .tag a { color: #000; padding-right: 10px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px; margin-right: 5px; } .tag span { padding-right: 10px; padding-left: 0px; padding-top: 5px; padding-bottom: 5px; } .note { position: fixed; bottom: 10px; text-align: center; width: 100%; } </style></head><body> <div class='container'> <div id='app'> <div class='tagHere'></div> <input type="text" /> </div> </div> <div class='note'>Use Tab to input a tag.</div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='https://code.jquery.com/jquery-2.2.4.min.js'></script> <script >$(document).ready(function(){ var $input = $("#app input"), $appendHere = $(".tagHere"), oldKey = 0, newKey, TABKEY = 9; $input.focus(); $input.keydown(function(e){ if(e.keyCode == TABKEY) { if(e.preventDefault) { e.preventDefault(); if($(this).val() == '' || $(this).val() == ' ') { return false; } addTag($(this)); } return false; } if($(this).val() == '' && e.keyCode === 8) { $(".tag:last-child").remove(); } }) function addTag(element) { var $tag = $("<div />"), $a = $("<a href='#' />"), $span = $("<span />"); $tag.addClass('tag'); $('<i class="fa fa-times" aria-hidden="true"></i>').appendTo($a); $span.text($(element).val()); $a.bind('click', function(){ $(this).parent().remove(); $(this).unbind('click'); }); $a.appendTo($tag); $span.appendTo($tag); $tag.appendTo($appendHere); $(element).val(''); } }); //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: