Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a basic example. It's actually really simple, but obviously without knowing the full user scenario there will be issues with it that will require you to tweak.</p> <p>Demo: <a href="http://jsfiddle.net/dj9xS/3/" rel="nofollow">http://jsfiddle.net/dj9xS/3/</a></p> <p>The problems:</p> <ol> <li>Doesn't detect sides of window, so tool tip could potentially be outside of window.</li> <li>There is no event to make tool tip disappear without clicking on "i" image again.</li> </ol> <p>HTML:</p> <pre><code>&lt;style&gt; dl { width: 300px; margin: 0 auto; } .lfm_info { position: relative; width: 16px; } .tooltip { display: none; background: black; width: 120px; position: absolute; bottom: 20px; left: 50%; margin-left: -68px; color: #fff; padding: 10px; } &lt;/style&gt; &lt;dl&gt; &lt;dt class="lfm_art"&gt; &lt;a href="http://www.last.fm/music/Red+Hot+Chili+Peppers/_/Californication" title="Clique para ouvir Californication no last.fm" target="_blank"&gt;&lt;/a&gt; &lt;img src="http://userserve-ak.last.fm/serve/34s/42739473.png" alt="Artwork de Californication"&gt;&lt;img src="http://userserve-ak.last.fm/serve/34s/42739473.png" alt="Artwork de Californication"&gt;&lt;/dt&gt; &lt;dd class="lfm_song"&gt;2. Californication2. Californication&lt;/dd&gt; &lt;dd class="lfm_artist"&gt;Red Hot Chili PeppersRed Hot Chili Peppers&lt;/dd&gt; &lt;dd class="lfm_info"&gt;&lt;img src="http://phpdev.dei.isep.ipp.pt/i101524/lastfm-widget/images/info.png"&gt;&lt;div class="tooltip"&gt;&lt;/div&gt;&lt;/dd&gt; &lt;/dl&gt; &lt;dl id="ajaxReference"&gt; &lt;dt class="lfm_art"&gt; &lt;a href="http://www.last.fm/music/Red+Hot+Chili+Peppers/_/Californication" title="Clique para ouvir Californication no last.fm" target="_blank"&gt;&lt;/a&gt; &lt;img src="http://userserve-ak.last.fm/serve/34s/42739473.png" alt="Artwork de Californication"&gt;&lt;img src="http://userserve-ak.last.fm/serve/34s/42739473.png" alt="Artwork de Californication"&gt;&lt;/dt&gt; &lt;dd class="lfm_song"&gt;2. Californication2. Californication&lt;/dd&gt; &lt;dd class="lfm_artist"&gt;Red Hot Chili PeppersRed Hot Chili Peppers&lt;/dd&gt; &lt;dd class="lfm_info"&gt;&lt;img src="http://phpdev.dei.isep.ipp.pt/i101524/lastfm-widget/images/info.png"&gt;&lt;div class="tooltip"&gt;&lt;/div&gt;&lt;/dd&gt; &lt;/dl&gt; ​ </code></pre> <p>jQuery:</p> <pre><code>$('.lfm_info').click(function(){ var toolTip = $(this).children('.tooltip'); // Get data using AJAX // Not sure how you are requesting data, maybe by unique ID? Need to put into each track dl to // reference. e.g. $(this).parent().attr('id'); // If success populate into tooltip on $(this).children('.tooltip') // $(this).children('.tooltip').text(ajaxData); toolTip.text('Hello World'); // If fail // return false; if(toolTip.is(':visible')){ toolTip.fadeOut(500); return false; }; // Check if any other tooltips are visible if($('.tooltip').is(':visible')) { $('.tooltip').fadeOut(500, function(){ toolTip.fadeIn(500); }); } else { toolTip.fadeIn(500); }; });​ </code></pre> <p>I hope this is helpful for you though.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload