排除选择单击通过Jquery

Ric*_*ckD 5 jquery

当我用一类父母点击tr上的任何地方时,我试图触发一个动作.当我点击其中一个下拉框时排除.

$('tr.parent')
    .css("cursor", "pointer")
    .click(function (e) {
        if($(e.target).not('select')){
            // do something
    }
Run Code Online (Sandbox Code Playgroud)

我尝试以下但这不起作用.

http://jsfiddle.net/0Lh5ozyb/60/

mal*_*ody 1

This should solve the issue for both Chrome and Firefox:

$('tr.parent')
    .css("cursor", "pointer")
    .click(function (e) {                   
        if ($(e.target).is('select') || $(e.target).is('option')) {
            //
        } else {
            $(this).css('background-color', 'red');
        }
    });

$('tr[class^=child-]').find('td > div, td').hide();
Run Code Online (Sandbox Code Playgroud)

JSFiddle test

Edit: Simplified version if you don't need to do any action when the select is clicked.

$('tr.parent')
    .css("cursor", "pointer")
    .click(function (e) {               
        if (!($(e.target).is('select') || $(e.target).is('option'))) {
            $(this).css('background-color', 'red');
        } 
    });

$('tr[class^=child-]').find('td > div, td').hide();
Run Code Online (Sandbox Code Playgroud)

JSFiddle test