首页 > 解决方案 > 将 .text() 转换为 .val()

问题描述

我有一个复选框列表。选中后,输出进入 id=output 的 div

如何将输出放在我的输入字段中?id=标签

$("#phoneword input").click(function () {
  $("#output").text($("#phoneword input:checked").map(function () {
    return $(this).val();
  }).get().join());
}).click().click();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<div id="phoneword">
<input type="checkbox"  class="form-check-input" name="phoneword" value="1"/>
<input type="checkbox"  class="form-check-input" name="phoneword" value="2"/>
<input type="checkbox"  class="form-check-input" name="phoneword" value="3"/>
</div>

<input type="text" data-role="tagsinput" class="tags" id="tags">
<div id="output"></div>

标签: javascriptjquery

解决方案


推荐阅读