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

时间:2013-10-11 07:29:50

标签: javascript jquery select colorbox onchange

以下是我的代码段:

    <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});

    });
  });

我想在选择相关选项时显示相应的颜色框。我尝试过如上操作但无法调用标识为deletePopContentdisablePopContent的Colorbox。我已经包含了所有必要的库,并且firebug控制台中没有错误或警告。有人可以帮我显示彩盒吗?先谢谢。

1 个答案:

答案 0 :(得分:0)

使用以下代码:

$(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});

    });
  });