Lex V
Lex V

Reputation: 1447

Affect the text click to a checkbox in Reactjs

How to affect a text click to a checkbox? Now it works as when we click on a checkbox it is selected, I want to select it while I'm clicking on the corresponding text also. Here my code,

<tr key={taskList.PriorityID}>
            <td style={{'width':'100px'}}><input type='radio' id={taskList.ID} name={'ID: ' + taskList.ID} onClick={_onclick} checked={selected} /></td>
            <td className="dashboard-post-payment_table-cell" title={'TaskList: ' + taskList.Priority}>{taskList.Priority}</td>     
</tr>

enter image description here

Upvotes: 0

Views: 44

Answers (1)

Karan Kiri
Karan Kiri

Reputation: 316

Try wrapping your text into label element like below.

<td style={{'width':'100px'}}>
   <input type='radio' id={taskList.ID} name={'ID: ' + taskList.ID} onClick={_onclick} checked={selected} />
</td>
<td className="dashboard-post-payment_table-cell" title={'TaskList: ' + taskList.Priority}>
 <label for={'ID: ' + taskList.ID}> {taskList.Priority}</label> 
</td> 

Upvotes: 1

Related Questions