mercredi 21 février 2018

set checkbox and span in the same line and add a clickevent to the span

I am kind of embarrassed that I can't find a solution to this simple task.

It is easy to make a checkbox and a span-tag in the same line, which what I have done liek this:

<label class='checkbox' for='visible_1'>
    <input id='visible_1' class='visible' type='checkbox'>
    <span>Layer_1</span>
</label>

I set a function to the checkbox, which show/hide the layer_1 and works pretty good. I also set a event with jQuery to the span-tag, which show some text in the website, but then I got a problem, I can't "touch" the text of span, the checkbox kinda of blocks the text, no matter where I click, as long as I click in the line, which checkbox and span are in, I can only select the checkbox.

It seems like the checkbox takes the whole line and the click event on span-tag is blocked by checkbox.

I don't know how it can be done, cause I don't want the checkbox to take a line and the span-tag another, it's even worse.




Aucun commentaire:

Enregistrer un commentaire