javascript - How to display pop up div for dynamically created database elements -


i have grid of 40 thumbnails of staff images , i'd display additional text (mainly biography) when user hovers on each element.

i've tried using jquery powertip (http://stevenbenner.github.io/jquery-powertip/) job, don't know how dynamically create each tooltip connect each thumbnail.

my javascript skills quite poor, i'm hoping can show me how display pop div unique each person on hover next each item?

<div class="people-list-container"> <ul class="people-list">  <a href="/person/details/8045">     <li>         <img src="8045.jpg" class="img-polaroid" />         bob smith                                            <br />         australia     </li> </a>  <a href="/person/details/8046">     <li>         <img src="8046.jpg" class="img-polaroid" />         jill jane                                            <br />         australia     </li> </a>  <a href="/person/details/8047">     <li>         <img src="8047.jpg" class="img-polaroid" />         john doe                                            <br />         australia     </li> </a>      // etc etc  </ul> </div> 

working fiddle code... hover on images see tooltip

the jquery function cycle each element class img-polaroid , set title displayed popup powertip function.

http://jsfiddle.net/9tctx/1/

$( document ).ready(function() {     $(".img-polaroid").each(function(index,element){         $(element).attr('title','element @ ' + index);         $(element).powertip({             placement: 'se' // north-east tooltip position         });;     }); }); 

html

<div class="people-list-container"> <ul class="people-list">  <a href="/person/details/8045">     <li>         <img src="8045.jpg" class="img-polaroid" />         bob smith                                            <br />         australia     </li> </a>  <a href="/person/details/8046">     <li>         <img src="8046.jpg" class="img-polaroid" />         jill jane                                            <br />         australia     </li> </a>  <a href="/person/details/8047">     <li>         <img src="8047.jpg" class="img-polaroid" />         john doe                                            <br />         australia     </li> </a>      // etc etc  </ul> </div> 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -