Home > Web Front-end > HTML Tutorial > How to use simple js/css to achieve that when a row is selected, the previous radio button is also selected? _html/css_WEB-ITnose

How to use simple js/css to achieve that when a row is selected, the previous radio button is also selected? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:15:00
Original
1609 people have browsed it

There is a list, and you can select any position in the row to achieve:
1. Select the row to become highlighted
2. The radio button in the first column is also selected

Now the highlighting of this row is implemented, but the radio button is also selected but not. .
How to write js to achieve this?

Thanks in advance~


Reply to the discussion (solution)

In the click event

onclick="xx(this)"

function xx(obj)
{
p = obj.parentNode
while(p.tagName!="TR") p=p.parentNode
}

p.cells[0].getElementsByTagName("input")[0].checked=true

In the click event

onclick="xx(this)"

function xx(obj)
{
p = obj.parentNode
while(p.tagName!="TR") p=p.parentNode
}

p.cells [0].getElementsByTagName("input")[0].checked=true

Thanks, that's basically it.
Because I set the onclick event on tr, I only need to write the following sentence:
obj.cells[0].getElementsByTagName("input")[0].checked = true;

Thank you very much~

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template