如何格式化输入文本字段中的文本

时间:2013-10-01 06:54:35

标签: html css

我正在创建一个类似于stackoverflow.com的应用程序。对于发布我们添加标签的问题,我想知道如何在输入逗号后更改文本样式。

1 个答案:

答案 0 :(得分:0)

您需要使用JS。

这就是逻辑的样子。它只是一个基本模板,可以帮助你入门。

<input type="text" onchange="tagit()" id="tags" />
<script>
function tagit(){
  var tags=$("#tags").val() //get the value of the input tag.
  // break the tags based on comma
  // wrap each tag around a <span> element
  // style the <span> element
}
</script>

您还可以在jQuery http://api.jquery.com/change/

中查看 .change()事件
相关问题