css - how to make a reference to a section with javascript? -


i need make reference section of site , don't know how ( have started stdy it) made .js function agrees change background color of body. made this:

function changebackground() {   var rd = parseint(document.getelementbyid('red').value); var gn = parseint(document.getelementbyid('green').value); var bl = parseint(document.getelementbyid('blue').value);   var rdhex = (rd < 16) ? "0" + rd.tostring(16) : rd.tostring(16); var gnhex = (gn < 16) ? "0" + gn.tostring(16) : gn.tostring(16); var blhex = (bl < 16) ? "0" + bl.tostring(16) : bl.tostring(16);  // create variable concatenates parts var hexcode = "#" + rdhex + gnhex + blhex;   document.body.style.backgroundcolor = hexcode; document.getelementbyid('hexdisplay').innerhtml = hexcode;  } 

as u can see applyed changecolor body (second-last command line) how can apply section of site?

you have define section using div tag, example. then, add id attribute can identify it.

<div id="leftsection"> ... </div> 

then, in javascript, div element:

var leftsection = document.getelementbyid("leftsection"); leftsection.style.backgroundcolor = hexcode; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -