Here is my js:
function showMore() {
document.getElementById("watch-description").style.display = "block";
document.getElementsByClassName(".yt-card.yt-card-has-padding").style.padding = "15px";
}
function showLess() {
document.getElementById("watch-description").style.display = "none";
document.getElementsByClassName(".yt-card.yt-card-has-padding").style.padding = "15px 15px 10px 15px";
}
Why does my button with js function not work?
One of two buttons:
<button class="yt-uix-button yt-uix-button-size-default yt-uix-button-expander yt-uix-expander-head yt-uix-expander-body" type="button" onclick="showLess();">
document.getElementsByClassName()does not return a single element. It returns anHTMLCollectionthat you will need to index before you can set styles.