English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hey great news is ...my code works...but it looks so novice...How could I optimize my code without changing the output. In otherwords, How do I improve my coding practice.Your help is greatly appreciated.

[CODE]







Title One

welcome to the first subitem

Title Two


Title Three






[/CODE]

2006-11-14 03:11:33 · 4 answers · asked by advisor 2 in Computers & Internet Programming & Design

4 answers

reference every thing as if they were arrays....

to switchDiv(param) you look through the array, and hide unless the index = param.

use css, and don't deal with alll those style attrs. just slap on a new className!

extra credit if you take the onclick out of the html and put it in the script where it belongs!

2006-11-14 05:21:58 · answer #1 · answered by jake cigar™ is retired 7 · 0 0

Instead of explicit characteristics in the internal script could you use named classes in an external css?

2006-11-14 03:30:11 · answer #2 · answered by fjpoblam 7 · 0 0

function SwitchDiv(objId){
var titleDiv1 = document.getElementById("title1");
var titleDiv2 = document.getElementById("title2");
var titleDiv3 = document.getElementById("title3");

contentDiv1.style.display ="none";
contentDiv2.style.display ="none";
contentDiv3.style.display ="none";

titleDiv1.style.color= "#ffffff";
titleDiv1.style.backgroundColo...
titleDiv2.style.color= "#ffffff";
titleDiv2.style.backgroundColo...
titleDiv3.style.color= "#ffffff";
titleDiv3.style.backgroundColo...

if(objId ==1){
contentDiv1.style.display ="block";
titleDiv1.style.color= "#000000";
titleDiv1.style.backgroundColo...
}else if(objId ==2){
contentDiv2.style.display ="block";
titleDiv2.style.color= "#000000";
titleDiv2.style.backgroundColo...
}else{
contentDiv3.style.display ="block";
titleDiv3.style.color= "#000000";
titleDiv3.style.backgroundColo...
}
}

Though, it can stil b customized...

2006-11-14 03:36:37 · answer #3 · answered by Snake 2 · 0 1

for sure your scripting this in notepad, with out syntax spotlight, or you may have seen the difficulty sparkling as day. document.write("

the present time is " + hour + ":" + minutes + ". the present day is " + day + "./h6") I recommend you acquire Notepad2 to code with

2016-10-17 06:32:24 · answer #4 · answered by ? 4 · 0 0

fedest.com, questions and answers