Jq realizes clicking on other areas of the page to hide the drop-down list

 The page structure is shown in the figure. To hide the drop-down list by clicking other areas outside the drop-down list, click the drop-down list area to not hide it.

code show as below:

//点击空白处隐藏多选下拉框
$(document).bind("click", function (e) {
    var searchTable = $(".source_data_tab");
    if (!searchTable.is(e.target) && searchTable.has(e.target).length === 0) {
        $(".source_data_tab").hide();
    }
});

 source_data_tab is the class name of the div tag of the drop-down list to be hidden.

 

 

Guess you like

Origin blog.csdn.net/liangmengbk/article/details/109073660