G
Guest
I sometimes used js like this
<head>
<script language='Javascript'>
function offDiv(div) {
document.getElementById(div).style.display='none'
}
function onDiv(div) {
document.getElementById(div).style.display='block'
}
</script>
</head>
associated to buttons like
<button onclick=offDiv("lc") style="border-style: none" >hide</button>
<button onclick=onDiv("lc") style="border-style: none" >show</button>
to hide or show a specific piece of HTML enclosed in a <div id=lc></div>
Now I want instead to act on ALL divs with <div class=lc>.
I have several pieces of text (normally class=lc causes them to be shown
on a light yellow bkg) interspersed here and there in the page, which I
want to hide or show all together.
I do not want to give a separate id to each.
How can I act on all ids of the same class ?
<head>
<script language='Javascript'>
function offDiv(div) {
document.getElementById(div).style.display='none'
}
function onDiv(div) {
document.getElementById(div).style.display='block'
}
</script>
</head>
associated to buttons like
<button onclick=offDiv("lc") style="border-style: none" >hide</button>
<button onclick=onDiv("lc") style="border-style: none" >show</button>
to hide or show a specific piece of HTML enclosed in a <div id=lc></div>
Now I want instead to act on ALL divs with <div class=lc>.
I have several pieces of text (normally class=lc causes them to be shown
on a light yellow bkg) interspersed here and there in the page, which I
want to hide or show all together.
I do not want to give a separate id to each.
How can I act on all ids of the same class ?