Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the html,

HTML
<li class="dropdown-submenu">
    <a tabindex="-1" href="#">
        <input type="checkbox" class="DDLProductCate" value="1">
        Construction Products
    </a>
    <ul class="dropdown-menu">
        <li>
            <a href="#">
                <input class="DDLProductCate" value="5" type="checkbox">
                Cement
            </a>
        </li>
        <li>
            <a href="#">
                <input class="DDLProductCate" value="6" type="checkbox">
                Steel
            </a>
        </li>
    </ul>
</li>


What I have tried:

How can I check a checkbox when clicks its on 'a' element text?

please help me...
Posted
Updated 19-May-17 0:18am
v3

1 solution

Try to put it in a label:

<a href="#">
  <label>
    <input type="checkbox" /> click to check
  </label>
</a>


JSFiddle
 
Share this answer
 
Comments
Member 12955507 19-May-17 5:51am    
ya its working! but some issue occurring, I am using bootstrap multilevel drowpdownlist with checkbox. But after add this label then click on it then it is disappearing drowpdown checked item. I have updated added my style code above. Please help me to rearrange the style with now added label.
Member 12955507 19-May-17 6:19am    
Hello, thanks. It is now working. I did write a jquery for open bootstrap. like: $('li.dropdown-submenu a').on('click', function (event) {
$(this).parent().parent().parent().toggleClass('open');
});
Member 12955507 19-May-17 6:31am    
Is this right code for prevent bootstrap dropdown close using by this code ? $(this).parent().parent().parent().parent().parent().toggleClass('open');

But this code is working well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900