User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,260 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,343 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Can't change CSS style for "onClick" text link

Join Date: Feb 2008
Posts: 5
Reputation: zabindia is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zabindia zabindia is offline Offline
Newbie Poster

Solution Re: Can't change CSS style for "onClick" text link

  #5  
Feb 27th, 2008
The below code what you have suggested earlier doesnt work...

<script>function changeStyle(id, newClass){   
 document.getElementById(id).style.className = newClass;}
</script>

sytle.className will not work when used with document.getElementById
it should be document.getElementById(id).className

instead u need to use this code

<script>
		function changeStyle(id, newClass){
		document.getElementById(id).className = newClass;
</script>
	}
  1. <td id="oneTd" class="style1" onclick="changeStyle(this.id, 'style2');" >Hello</td>
Last edited by peter_budo : Feb 27th, 2008 at 2:48 pm. Reason: Extensive use of colour tags is not best idea
Reply With Quote  
All times are GMT -4. The time now is 10:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC