jquery - JavaScript: Cant work out how to get a roll over to work on multiple elements -


this 1 simple, has been racking brain ruins few days now. have php script outputs images, , on each out-putted image, when user hovers on elements shows info & options. can seem work out how each element it's id, doesn't work, allowing first outputted image show it's rollover, id's should unique way useless. did getting elements classes in jquery had problem, every time hovered image of hidden elements shown, mouse on over image 1 showing options images 1,2,3,4,5,6,7,8.... grrrr!

so tis original javascript used:

function thumbtoggle() {         var opt = document.getelementbyid("rem");         var text = document.getelementsbytagname("thumbrem");             if(opt.style.display == "block") {                 opt.style.display = "none";                 text.innerhtml = "↓";             }             else {                 opt.style.display = "block";                 text.innerhtml = "↑";         }     } 

pretty simple really, knowledge of js. js didn't work me, nor did jquery. idea have sort add id , concatenate incremented number after it, making each id unique, doing same thing id's in html, making id's match.

only problem have no clue how it, have no clue if work , think it's time put hands , admit need stack overflow lovage.

here piece of php out puts images....

// image output  <div style='position:relative; display:inline; width:200px; overflow:hidden;'>     <div style='position:relative;'>         <a id="thumbrem" onmouseover='thumbtoggle();' class='thumbrem' style='position:relative;' href=\"show-image.php?id=$id\">             <img class='lifted drop-shadow' src=\"thumb.php?id=$id\">         </a>  // element appears on rollover  <div id='rem' class='rem'>                <div style='padding-bottom:5px;'>       <label style='color:#fff;'>select:</label>          <form method=\"post\" action='myimages.php'>            <input type='checkbox' name='images[]' value='$id'>&nbsp;&nbsp;          </form>                      </div>       <div style='color:#fff;'>       <a href=\"myimages.php?id=$id&act=delete\">delete</a>              &nbsp;|&nbsp;           <a class='' href=\"myimages.php?id=$id&act=changetags\">edit tags</a>      </div>   <div style='color:#fff; padding-bottom:3px;'>size:{$details[$i]}</div>  <div style='color:#fff padding-bottom:3px;'>date:  {$date[$i]}</div>  <div style='color:#fff'>views:  {$views[$i]}</div>      </div>           </div> 

cheers guys , girls reading, hope hear of soon.

cheers in advance, jamie

within javascript event handler, keyword this html element handler attached.

so don't need have autoincremented id in thumbtoggle function. use retrieve hovered link.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -