juniper747;10997252 wrote:
which one do you think would be more simpler or efficient to implement? Ie using class instead of id.
I agree with everything brad said. Use classes only for sttling purposes, that is to actually achieve the hidden/visible/whatever style you want.
juniper747;10997252 wrote:
As you said there may be a problem with your way if that memberID appears more than once on the page.
No. I said there would be a problem if you had the same value in more than one id attribute on the page. You can have the same memberID appear in as many event handler bindings as you want.
This is perfectly valid
<h3>2 is memberID</h3>
<div onmouseover="stuff(this, 2);"></div>
<div onmouseover="stuff(this, 2);"></div>
<div onmouseover="stuff(this, 2);"></div>
<div onmouseover="stuff(this, 2);"></div>
<div onmouseover="stuff(this, 2);"></div>
juniper747;10997252 wrote:
<script type="text/javascript">
var divs=document.getElementsByTagName("div")
for (var j = 0; j < divs.length; j++) {
if (divs[j].className=="showhide"){
I'd not recommend doing this. You are executing a javascript to find all functions with a given classname. But since either all of those elements have that classname every time, or you use server side scripting to decide if they do, at the time the page is generated you will alwasy know if they do or not. Thus, why not simplify things a whole lot, especially for anyone reading your code
<div class="showhide" onmouseover="stuff(this, $memberid);">
and get rid of the javascript. The function stuff() does of course have to be defined as a javascript funciton, preferably in a separate file referenced by
<script type="text/javascript" src="/path/to/file.js">
Use of deprecated mime type is to make several IE versions regard it as javascript.