문제

I've got this javascript code and some tr elements inside a table, but the click event simply doesn't work on this element, I've already tried on other elements, such as div, and it worked. Does anybody know why?

$(document).ready(function() {
    $('tr').bind('click',function(){
    alert('clicked');
    });
});
도움이 되었습니까?

해결책

Maybe, try an alternative to click or on methods. Have a look to these codes :

// With click
$(function() {
    $('tr').click(function(){
        alert('clicked');
    });
});

// With on
$(function() {
    $(document).on('click', 'tr', function(){
        alert('clicked');
    });
});

Check also if your tr is visible like this :

$(function() {
    if($('tr').is(':visible')) {
        alert('visible');
    }
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top