Last active
August 29, 2015 14:14
-
-
Save raribeiro/32dc9665d57a01ade0a7 to your computer and use it in GitHub Desktop.
Simple show and hidden any component linked with upload in pure Javascript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show or hidden upload degree | |
*/ | |
//Element action | |
var elUploadAction = document.getElementById('uploadDefaultButton'); | |
//check if action is true | |
if(elUploadAction){ | |
//Real action | |
var showHiddenUpload = function(){ | |
var elHides = document.querySelectorAll('.degree-upload'); | |
var numelHides = elHides.length; | |
var status; | |
while(numelHides--){ | |
if(window.getComputedStyle(elHides[numelHides], null).getPropertyValue('display') === 'none'){ | |
status = true; | |
elHides[numelHides].style.display ='inherit'; | |
}else{ | |
elHides[numelHides].style.display = 'none'; | |
status = false; | |
} | |
if(!numelHides){ | |
if(status){ | |
this.innerHTML = 'hide'; | |
}else{ | |
this.innerHTML = 'send'; | |
} | |
numelHides = elHides.length; | |
break; | |
} | |
} | |
}; | |
} | |
elUploadAction.addEventListener('click', showHiddenUpload, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment