PDA

View Full Version : adding tab heading highlight to script



rich1234
04-24-2008, 09:40 PM
Switch Content Script II (icon based)

http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm

Hi, This is not a problem but a query. I was wondering if an enhancement to this script were possible. Could the title of each content heading like
"What is JavaScript?" be highlighted when it is expanded? I have them as links
<a class="mena" href="/" title="">What is JavaScript?" </a>
so I was wondering if one could switch a classes when expanded.
Its just a thought



<div class="eg-bar"><span id="faq1-title" class="iconspan"><img src="minus.gif" /></span>What is JavaScript?</div>

Thanks
Richard

rangana
04-25-2008, 12:51 AM
Yes...it's possible :)

Add this script in the head section:


<script type="text/javascript">
window.onload = function()
{
var obj=document.body.getElementsByTagName('div');
for(var start=0;start<obj.length;start++)
{
obj[start].onclick=function()
{
this.className = (this.className != 'eg-bar')? 'eg-bar': 'rangeg-bar';
}
}
}
</script>


...Then include this code in your CSS rule ;)


.rangeg-bar
{background:#9cf;width:500px;
font-weight: bold;
border: 1px solid black;
padding: 3px;}


See if it helps :)