Here is the test page:
http://grozav.com/test.php
I’m trying to add a jquery function to each image from the mysql database table.
Here is the generated code:
<div class="thumb" id="grozav-thumb">
<a class="ajax" href="gallery/grozav.html">
<p class="work-type">MOTION GRAPHICS</p>
<img src="http://grozav.com/images/thumbs/grozav-bwthumb.jpg" alt=""/>
<img src="http://grozav.com/images/thumbs/grozav-thumb.jpg" alt="" class="color"/>
</a></div>
I need a function which creates a code for each div with the class thumbnail. The outcome should be like this:
*thumbnail() is a function
thumbnail('divid');
which is something like
thumbnail('grozav')
Thanks a lot!
After reading the advices here, I’ve changed the code into:
function thumbnail(param1){
$(param1).hover(
function() {
$(param1+' .color').hide().stop().fadeTo(500,'1');
},
function() {
$(param1+' .color').stop().fadeTo(500,'0');
}
) ;
};
for(var p in document.querySelectorAll('div.thumb'))
thumbnail(p.id);
EDIT
Problem solved.
I used the following jQuery code to do it, which seems to work fine.
$("div.thumb").each(function (){
var id = $(this).attr('id');
thumbnail(id);});
Applies the function to each of the divs created through php. Thank you anyway guys!
Problem solved. I used the following jQuery code to do it, which seems to work fine.
Applies the function to each of the divs created through php. Thank you anyway guys!