0

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

Karan Kiri
  • 316
  • 2
  • 12
Lex V
  • 1,414
  • 4
  • 17
  • 35
  • Possible duplicate of [How to create a checkbox with a clickable label?](https://stackoverflow.com/questions/6293588/how-to-create-a-checkbox-with-a-clickable-label) – Karan Kiri Oct 16 '19 at 05:29

1 Answers1

1

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> 
Karan Kiri
  • 316
  • 2
  • 12