javascript - Using jQuery, a Dropdownlist should only be visible if at least 1 checkbox is selected -
I have the link, when clicked, select or deselect all checkboxes.
I also have the dropdown list which I would like to show if at least one checkbox is selected.
What is the best way to do this?
Should I enter the code inside the code that he chooses / deletes it or is there a better way of doing this?
I will have a function that sets the visibility of the dropdown I will assign this function to each checkbox and link handler I would say click handlers - I assume that your link handlers do not fire only one click event on each box, but set its position. Unless you have any other behavior to trigger click event firing on each checkbox, it will be very expensive, use the test of the set in your function, use a test, to see if the number of check boxes visibility Is more than 0 for.
function setDDVisibility () {var isvisible = $ ('.checkbox-class-selector: checked'). Length & gt; 0; If (invisible) {$ ('# ddl'). Show (); } And {$ ('# ddl'). Hide (); }} $ ('Checkbox-square'). Click (function () {... do stuff ... setDDVisibility (); return false;}); $ ('Link-selector'). Click (function () {... set up checkbox ... set DD viability (); return returned;});
Comments
Post a Comment