Skip to content

Instantly share code, notes, and snippets.

@raribeiro
Last active August 29, 2015 14:14
Show Gist options
  • Save raribeiro/32dc9665d57a01ade0a7 to your computer and use it in GitHub Desktop.
Save raribeiro/32dc9665d57a01ade0a7 to your computer and use it in GitHub Desktop.
Simple show and hidden any component linked with upload in pure Javascript.
/**
* 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