First question ever here. I'm a bit nervous to break the ice, please be indulgent I just finished the CodeAcademy JS lessons.
In the following code that I found to toggle some of my #element, I guess that it switches my class.property from its initial state to "block", and from "block" to its initial state. Correct me if I'm wrong. But if I'm not, can someone explain to me how does this is performed?
class.property === 'value' ? '' : 'value';
Question Mark in JavaScript - condition ? value-if-true : value-if-false
At this point I understand that ' ' is equal to 'none', it makes sense. Then it finally pass this property conditon value-if-true and value-if-false to my #element (which is trigged with some onclick(). But what if now I want that my function to also trigger some section position:?
I tried to add this, but it failed. I also don't understand why using (function() {})();
(function (style) {
style.display = style.display === 'fixed' ? 'absolute' : 'fixed';
})(document.getElementById(section).style);
Here is the original code :
function toggledisplay(elementID) {
(function (style) {
style.display = style.display === 'block' ? '' : 'block';
})(document.getElementById(elementID).style);
};