当没有从表中选择任何记录时,如何在按钮上放置模式.我正在使用引导程序 4


<table id="resultTable" class="table table-hover table-bordered table-sm">
  <thead>
    <tr>
      <th>Select</th>
      <th>Message Id</th>
      <th>Service</th>
      <th>Date</th>
    </tr>
  <thead>
  <tbody>
    <tr>
      <td>
        <div class="radio">
          <input type="radio" name="selectRow"/>
        </div>
      </td>
      <td>SomeId001</td>
      <td>SERVICE1</td>
      <td>2019/02/04</td>
    <tr>
  </tbody>
</table>
<br/>
<button id="proceedBtn" type="button" class="btn btn-light">Proceed</button>
$('#proceedBtn').click(function(){
    $('.nav-tabs > .active').next('li').find('a').trigger('click');
});

所以我想要的是显示一条消息,无论是在用户尝试使用继续按钮时以模式还是警报显示,但表中没有选择任何记录。如果从表中选择了记录,则用户可以使用该按钮,但在选择记录之前,该按钮不应具有任何功能。选择记录后,继续按钮将执行上述javascript。我一直在试图找到一个例子,但由于我对javascript和bootstrap不是很熟悉,所以我没有找到适合我的例子。

我不知道

我是否正确理解了您的要求,但可能这样的东西可以适合......:

$('#proceedBtn').click(function(){
  var selectRowElement = document.getElementsByName('selectRow');
  if (selectRowElement.checked) {
    $('.nav-tabs > .active').next('li').find('a').trigger('click');
  } else {
    alert('Please select a row before proceeding');
  }
});

最新更新