Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open / Close Div NOT working

Status
Not open for further replies.

hiyatran

Technical User
Aug 7, 2010
21
CA
My code works but when I put an image in there my code doesn't work anymore.

<html>
<head>
<style type="text/css">
.planType{display:none; width:600px}

</style>

<script type="text/javascript">
<!--
function planTypeOpen(planID) {
document.getElementById('info_' + planID).style.display = "block";
document.getElementById('title_' + planID).innerHTML="<a href=\"javascript:planTypeClose('" + planID + "');\">Check this out" + "</a>";
}

function planTypeClose(planID) {
document.getElementById('info_' + planID).style.display = "none";
document.getElementById('title_' + planID).innerHTML="<a href=\"javascript:planTypeOpen('" + planID + "');\">Check this out" + "</a>";
}
//-->
</script>
</head>


<body>

<div id="title_1"><a href="javascript:planTypeOpen('1');">Check this out</a></div>
<div id="info_1" class="planType">
You can't see me...<br>
Or Can you??
</div>

</body>
</html>

any comments would be greatly appreciated.

 
I would like to insert an image in my javascript function but it does NOT work. So it goes like this...

document.getElementById('title_' + planID).innerHTML="<a href=\"javascript:planTypeClose('" + planID + "');\">Check this out" + "</a>" + "<img src="image.jpg">";

any ideas??

 
hmm.
you know enough to escape the quotes in the href attribute of the 'a' element
but you don't escape the quotes in the src attribute of the 'image' element
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top