How to find the parent element using javascript

后端 未结 2 1486
情歌与酒
情歌与酒 2020-12-25 10:00

I want to change the background color of the table cell when radio button inside the cell is clicked.

相关标签:
2条回答
  • 2020-12-25 10:29

    Using plain javascript:

    element.parentNode
    

    In jQuery:

    element.parent()
    
    0 讨论(0)
  • 2020-12-25 10:36

    Use the change event of the select:

    $('#my_select').change(function()
    {
       $(this).parents('td').css('background', '#000000');
    });
    
    0 讨论(0)
提交回复
热议问题