How can I add .live to the to the following function?
$(document).ready(function(){
$.fn.vAlign = function() {
return this.each(function(i){
var ah = $(this).height();
var mh = (368 - ah) / 2;
$(this).css('margin-top', mh);
});
};
$('div.slideshow img').vAlign();
});
I need to add live because div.slideshow img is being generated by jQuery. The function doesn’t seem to work unless the div is already in HTML prior to the script being executed.
You can use livequery
this will make it so vAlign() gets executed on any element that matches your selection on load and anytime after.