Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Tagify">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Tagify</title>
  <meta name="author" content="Yair Even Or">
  <script src="https://unpkg.com/@yaireo/tagify"></script>
  <script src="https://unpkg.com/@yaireo/tagify@3.1.0/dist/tagify.polyfills.min.js"></script>
 <link href="https://unpkg.com/@yaireo/tagify/dist/tagify.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <button type='button'>Inject tag into last caret place</button>
  <br><br>
  
  <textarea>some text [[mixed]] with [[tags]].
    try placing the caret somewhere to click the button below to add a tag at that place
  </textarea>
  
</body>
</html>
 
var input = document.querySelector('textarea')
var tagify = new Tagify(input, {
  mode: "mix"
})
document.querySelector("button").addEventListener('click', ()=> {
    var tagElm = tagify.createTagElem({ value:"my tag" })
    tagify.injectAtCaret(tagElm)
    var elm = tagify.insertAfterTag(tagElm)
    tagify.placeCaretAfterNode(elm)
})
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
yairEOpro
0viewers