2

I was wondering how to change the following:

<li class="link">
<a href="https://some-url.com">Some Text</a>
</li>

In a way that I can have a text with a squared box, so that when I click on the box, I am redirected to the same url specified in the tag. If I click on the text, the box should be selected as well.

1

Something like this?

HTML:

<input id="mycheckbox" type="checkbox" onclick="location.href = 'https://some-url.com';">
  <a id="linkid" href="https://some-url.com">SomeText</a>

JQ:

$('#linkid').click(
  function() {
    $('#mycheckbox').prop('checked', true);
  }
);

Fiddle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.