paulclift Posted April 27, 2013 Share Posted April 27, 2013 I am trying to make a checkbox work with a label which is INSIDE an <a href> ..,the label function isn't working because of both the separate <div> in which it appears and also because of the anchors. Is there are work-around for this? Can I 'hard code' the labels with css or jscript so that they will work universally throughout the page? Easier if I just post the code rather than trying to explain: <div id="blah"><input type="checkbox" id="1" checked onclick="fnchecked(this.checked);"> <ul class="menu collapsible"> <li> <a href="#"> <div class="more"><label for="1">[+]</label></div> <div class="less"><label for="1">[–]</label></div> </a> <ul class="acitem"> <BR> <li>TEXT TEXT TEXT </li> </ul></li></ul> The page I am using this with is here: http://www.paulclift.net/news.htmlBasically, I am trying to have a plus/minus symbol which ALSO activates a drop-down menu. PLEASE HELP! Link to comment Share on other sites More sharing options...
jeffman Posted April 27, 2013 Share Posted April 27, 2013 I'm really not sure what the relationship is supposed to be between the + and - symbols and the checkbox. I will say that all this looks needlessly complicated. 1. What is the anchor doing there? If you just want :hover behavior, use CSS to put a hover effect on something else. I'm thinking of the <p> I mention in #3 below. 2. What are the divs doing there? If they exist as containers that can appear and disappear, they are extra. The stuff inside them can be made to do that. 3. But you don't need that. You don't need two elements. You need one element. A simple <p> would do everything you are now doing with on link, two divs, and 2 labels. Change the <p> innerHTML from [+] to [-] each time it is clicked. Add a click event listener that checks the innerHTML of the element and do one set of behaviors if the value is [+] and another set if the value is [-]. 4. You do not need a label. The click event listener on the <p> can update the checkbox too. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now