Sunday, August 2, 2009

How to use dhtml and css combination in coding?

how to use dhtml and css combination in coding?

How to use dhtml and css combination in coding?
Neither one necessitates the other. The most common way of using the two in tandem is to use javascript functions to schange the style on a given section of text or other content. For example, you might have a function that changes the style of a graphics span based on what text button the mouse is currently hovering over. This would have the effect of changing the image (or image location, whatever) based on what button the user might be about to push. Functional effect would be to implicitly provide more information about said button (pseudo-microhelp).





Just define all your desired styles first in the css file (or header). This would include distinct styles for whatever different states your page content might be in at any given time. Then go ahead and define your functions that would toggle them. You could even define a global class-switching function such as the one below to simply pass a element ID and class name to the function and toggle it at any event on your page.





%26lt;script language="javascript" type="text/javascript"%26gt;


function DoSomething (something,newclass) {


document.getElementById( something ).class = newclass;


}


%26lt;/script%26gt;


No comments:

Post a Comment