如何调用一个jQuery Colorbox弹出在选择HTML控件的onchange事件

How to call a jQuery Colorbox pop up on the onchange event of select HTML control?

本文关键字:选择 HTML 控件 onchange 事件 jQuery 调用 何调用 一个 Colorbox      更新时间:2023-09-26

以下是我的代码片段:

    <select  name="select_option">
      <option value="0">--Select Action--</option>
      <option value="1" class="delete_bulk_tests">Delete User</option>
      <option value="2" class="disable_bulk_tests">Disable User</option>
    </select>
    <div class="hidden">
      <div id="deletePopContent" class="c-popup">
        <h2 class="c-popup-header">Delete Users</h2>
        <div class="c-content">         
          <h3>Are you sure to delete selected users?</h3>
          <p class="alert"><strong>You are about to perform an action which can't be undone</strong></p>
          <a href="#"class="c-btn">No</a><a href="#"class="c-btn" id="delete_url">Delete</a> 
        </div>
      </div>
    </div>
<div class="hidden">
      <div id="disablePopContent" class="c-popup">
        <h2 class="c-popup-header">Disable Users</h2>
        <div class="c-content">         
          <h3>Are you sure to disable selected users?</h3>
          <p class="alert"><strong>You are about to perform an action which can't be undone</strong></p>
          <a href="#"class="c-btn">No</a><a href="#"class="c-btn" id="disable_url">Disable</a> 
        </div>
      </div>
    </div>
    $(document).ready(function()  {
    $(".delete_bulk_tests").onchange(function(e) { 
        $(".delete_bulk_tests").colorbox({inline:true, width:666});
    });
$(".disable_bulk_tests").onchange(function(e) { 
        $(".disable_bulk_tests").colorbox({inline:true, width:666});
    });
  });

我想在选择相关选项时显示相应的颜色框。我尝试了如上所述,但无法使用 id deletePopContentdisablePopContent 调用 Colorbox。我已经包含了所有必要的库,而且Firebug控制台中也没有错误或警告。谁能帮我显示颜色框?提前谢谢。

使用以下代码:

$(document).ready(function()  {
    $(".delete_bulk_tests").change(function(e) { 
        $(this).colorbox({inline:true, width:666});
    });
$(".disable_bulk_tests").change(function(e) { 
        $(this).colorbox({inline:true, width:666});
    });
  });