jQuery按钮将Tablesorter列的过滤器从选择切换为输入,反之亦然

问题描述 投票:0回答:1

我一直在尝试使用文本可切换的jQuery按钮来替换输入的特定列的HTML下拉列表,反之亦然。

dropdown-> insert->dropdown...

但是似乎搜索调用停止工作,我想有一种适当的可行方法来完成此任务,而不仅仅是替换HTML。

javascript jquery tablesorter
1个回答
0
投票

这可以使用CSS实现。这是使用css display属性的示例。

function toggleInput() {
  if ($("#inputBox").hasClass("hide")) {
      $("#selectBox").addClass("hide");
      $("#inputBox").removeClass("hide").addClass("show");
  } else {
    $("#inputBox").addClass("hide");
    $("#selectBox").removeClass("hide").addClass("show");
  }
}
.show {
  display: inline-block;
}

.hide {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button onclick="toggleInput()">Toggle input type</button>
<select id="selectBox">
  <option>Option 1</option>
  <option>Option 2</option>
</select>
<input class="hide" id="inputBox" type="text" value="" />
© www.soinside.com 2019 - 2024. All rights reserved.