javascript - How to change style of HTML element depending on another elements style? -
in web application changing style of html element using javascript.
see below code,
function layout() { if(document.getelementbyid('sh1').getattribute('src') == "abc.png") { document.getelementbyid("sh1").style.display="none"; } else { document.getelementbyid("sh1").style.display="block"; } }
and html :
<img id="sh1" src="abc.png" />
now want if img elements style display:none; below elements
<p id="text1">name<br />description</p>
style should changed display:none; , if img elements style display:block; above elements style should changed display:block; automatically.
how can achieved?
add other element in function too. this:
function layout(){ if(document.getelementbyid('sh1').getattribute('src') == "abc.png"){ document.getelementbyid("sh1").style.display="none"; document.getelementbyid("text1").style.display="none"; } else { document.getelementbyid("sh1").style.display="block"; document.getelementbyid("text1").style.display="block"; } }
or if put both in container can 1 operation on whole container =)
Comments
Post a Comment