English 中文(简体)
如何根据角移转值确定标签
原标题:How to set label based on toggle switch value

我使用诱杀装置5和我用开关。

如何根据交换价值确定Label。

这并不可行:

<div class="form-check form-switch">
  <input type="checkbox" class="form-check-input" id="status">
  <script>
   if ($( #status ).val() == 1) {
      <label for="site_state" class="form-check-label">Aktif</label>
   } else {
      <label for="site_state" class="form-check-label">Tidak Aktif</label>
   }
   </script>
</div>

任何人都有想法?

问题回答

利用j Query s change活动聆听检查箱上的改动。 当检查箱变更时,你可以检查其<编码>浸入<>条码>的财产,以确定其是否被检查,然后相应地更新标签。

<div class="form-check form-switch">
  <input type="checkbox" class="form-check-input" id="status">
  <label for="status" class="form-check-label" id="statusLabel">Tidak Aktif</label>
</div>

<script>
$(document).ready(function() {
  $( #status ).change(function() {
    if (this.checked) {
      $( #statusLabel ).text( Aktif );
    } else {
      $( #statusLabel ).text( Tidak Aktif );
    }
  });
});
</script>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签