Skip to content Skip to sidebar Skip to footer

Activate Label And Link With One Click

I want to make one click activate both, label and link, because my menu works with links and moves to the correct point of the page, but the label has to activate the button which

Solution 1:

I may be misunderstanding your intention but you might just try something like this instead.

Using your HTML with a quickie edit;

<labelfor="magicbutton">Click Me</label><inputid="magicbutton"type="checkbox"onclick='window.location.assign("#field")'/><divid="field"><p>
magic text
</p></div>

and your CSS with a quickie edit;

#field{
    display:none;
    position:absolute;
    top:100%;
}

input {float: left;}

input#magicbutton:checked ~ #field{
    display:block;
}

...and a fiddle https://jsfiddle.net/L2ywu2ta/

I didn't change much, hope it helps. Cheers.

Solution 2:

Technically not a link, but with some styling it might boil down to the same:

<formaction="#boxwithcontent"method="get"><label>test<buttontype="submit">Click me</button></label></form>

If you have several of them, you might use one form, and use the formaction attribute on the button...

Post a Comment for "Activate Label And Link With One Click"