I'm having a little issue right now that has turned into a festering wound.
I've recreated Google Business Hours for setting which hours during the week that a company is open, or whether they are closed on that day. Now, if they are closed, the user can select a checkbox and the times DIV hides. Right now I'm using .show()
and .hide()
Now, let's say that a user closes the first day and decides to "apply all" to the rest of the days of the week. I loop through and close the remaining 6 days. However, if a user has modified a day in the middle of the week, the .show()
or .hide()
functions automatically add "display: block"
and this messes up the loop.
Why is jQuery adding this styling when it was never there originally, and is there a clean way of removing it within a loop before I apply the .show()
or .hide()
?
On an element that you haven't defined the display, after unhidding it, JQUERY will add display block to the element.
You can remove it afterwards.
$("#myrow").show().removeAttr( 'style' )
This includes all dynamic styling so please watch out if you depend on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With