选择链接,自动选中左侧的复选框

Bra*_*rad 3 html jquery

我希望用户能够将鼠标悬停在链接上,单击它,它会自动选中左侧的复选框,当他们选择它时,它将取消选中该框.

我该怎么做呢?

<input type="checkbox" name="favorite_color" value="Orange"> <a href="#" rel="favorite_color">Orange</a>

Nic*_*ver 9

而不是链接(锚),使用<label>为此设计的:

<input type="checkbox" name="favorite_color" id="favorite_color" value="Orange"> 
<label for="favorite_color">Orange</label>
Run Code Online (Sandbox Code Playgroud)

或没有id,缠绕它:

<label><input type="checkbox" name="favorite_color" value="Orange"> Orange</label>
Run Code Online (Sandbox Code Playgroud)

有了这两个,就不需要JavaScript,只需要内置的浏览器行为.