So what I want to do is define the numerical range and execute a function for all the ID's on the page with that number except the ID with the number specified in the page.
So visually if you click on DIV4 of a total of nine divs then the range of IDs would be [1-3] + [5-9]. My goal for the script below is merely to change all the divs except for the one specified in the parameter when the function is called. I'm trying to do an alert to see the output but if anything all it's doing is adding up the numbers!
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Regex Range Except specified Parameter</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script type="text/javascript">// Class Changefunction change(id, newClass){identity=document.getElementById(id);identity.className=newClass;} function switcher(selected) {//change('div'+[0-9](?!selected), 'off');change('div'+selected, 'on');//alert('div'+[0-9?(?!selected)]);} </script><style type="text/css">div.off {background-color: #fff; color: #000;}div.on {background-color: #000; color: #fff;}</style></head> <body> <div id="my_divs"><div id="div1" onclick="switcher('1');">1</div><div id="div2" onclick="switcher('2');">2</div><div id="div3" onclick="switcher('3');">3</div><div id="div4" onclick="switcher('4');">4</div><div id="div5" onclick="switcher('5');">5</div><div id="div6" onclick="switcher('6');">6</div><div id="div7" onclick="switcher('7');">7</div><div id="div8" onclick="switcher('8');">8</div><div id="div9" onclick="switcher('9');">9</div></div><!-- /#my_divs --> </body></html>