Skip to content

Instantly share code, notes, and snippets.

@rodrigophpweb
Created July 29, 2021 13:38
Show Gist options
  • Save rodrigophpweb/4e967df8d66f9498c22d799610073c00 to your computer and use it in GitHub Desktop.
Save rodrigophpweb/4e967df8d66f9498c22d799610073c00 to your computer and use it in GitHub Desktop.
Function get all class with same name more width and height
function setDisplay(className, widthValue, heightValue) {
//Get All Class same name
var items = document.getElementsByClassName(className);
//Loop to Class
for (var i=0; i < items.length; i++) {
//Change Attributes Width and Height
items[i].style.width = widthValue;
items[i].style.height = heightValue;
}
}
//Callback with parameters
setDisplay('wp-caption', '100%', 'auto')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment