Note that there are some explanatory texts on larger screens.

plurals
  1. POrails jquery hover over li element to poplulate another div
    primarykey
    data
    text
    <p>Update: I'm working on some jquery that looks like this:</p> <pre><code>$(document).ready(function(){ $('li img').hover( var src = $(this).attr('src') function(){ $('#big').html('&lt;img src=' + src + '/&gt;'); }, function(){ $('#big').html(""); } ); }); </code></pre> <p>That didn't work...but this did:</p> <pre><code>$(document).ready(function(){ $('#li img').hover( function(){ $('#big').html('&lt;img src=' + $(this).attr("src") + '/&gt;'); }, function(){ $('#big').html(""); } ); }); </code></pre> <p>but the src variable usage isn't right. I'm also attempting to turn this into an array or hash to iterate through. Eventually the big box will iterate through the thumbnails and if the user hovers over the list element it will stop the iterating and display the big version of the list item hovered over. First need to get this part working!</p> <p>Thanks!</p> <p>I have a list which contains thumbnails. When you wand over the thumbnail I'd like another div to show the full screen image. I'm a little torn on the cleanest way to do it. I'll post my ugly solution last but first I'd like to show the direction i think i want to go.</p> <p>html:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;%= image_tag('rails.png') %&gt;Some text&lt;/li&gt; &lt;li&gt;&lt;%= image_tag('rails.png') %&gt;Some text&lt;/li&gt; &lt;li&gt;&lt;%= image_tag('rails.png') %&gt;Some text&lt;/li&gt; &lt;/ul&gt; &lt;div id='big'&gt;&lt;/div&gt; </code></pre> <p>so first off; the thumbnails and text will change. I'm attempting to use jquery of the form:</p> <pre><code>$('li').hover(function(){ $('#big').append("&lt;img src="'+ this.img.src + '" /&gt;"); }); </code></pre> <p>this.img.src is the where i'm failing.</p> <p>the working solution is VERY ugly in my opinion and it uses html like:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href='assets/rails.png"&gt;&lt;%= image_tag('rails.png') %&gt;Some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='assets/rails.png"&gt;&lt;%= image_tag('rails.png') %&gt;Some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='assets/rails.png"&gt;&lt;%= image_tag('rails.png') %&gt;Some text&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id='big'&gt;&lt;/div&gt; </code></pre> <p>jquery like:</p> <pre><code>$("#big").append("&lt;p id='preview'&gt;&lt;img src='"+ this img.src +"' alt='Image preview' /&gt;"+ c +"&lt;/p&gt;"); </code></pre> <p>I haven't posted enough of the working solution to work; just enough for anyone to get the idea.</p> <p>So how can clean up that garbage? I'd like to use the first html with no link tags (i don't feel it's necessary). I'm even looking generating the list with ruby iterating through a directory of images.</p> <p>Thanks for any direction you can offer.</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. This table or related slice is empty.
    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