Open a jquery dialog using prev() and parent()
I have a list of dialog boxes which I want to open when there assosciated icon is clicked on but not write a .click() function for each dialog. At the moment my html looks like this.开发者_如何学Go
<ul>
<li>
<img src="e_gift_ss/design_2_1.jpg" alt="Screenshot 1"/>
<img src="e_gift_ss/design_2_2.jpg" alt="Screenshot 2"/>
<img src="e_gift_ss/design_2_3.jpg" alt="Screenshot 3"/>
<img src="e_gift_ss/logo_designs.jpg" alt="Screenshot 4"/>
</li>
<li class="portfolio_link"><img src="link_img/e_gift.png" alt="e-Gift Voucher" class="icon png" id="e_gift_link"/></li>
<li>
<article>
<h4>Acer E-Gift Voucher</h4>
<p>Designed as a web portal for a after sale marketing promotion.</p>
</article>
</li>
</ul>
and my jquery looks like this
$('.portfolio_link').css({backgroundPosition: "-480px 0"});
$('.icon').parent().prev().dialog({resizable:false,autoOpen:false,draggable:false,width:860,height:pageheight,modal:true});
$('icon').click(function(){$(this).parent().prev().dialog('open');
});
Making the li element a dialog works fine but the .click function will not open the dialog.
Any ideas would be great
Cheers
Your last line of javascript code says:
$('icon').click(function(){$(this).parent().prev().dialog('open');
Maybe you did forget the dot before the classname icon?
So it should be
$('.icon').click(function(){$(this).parent().prev().dialog('open');
Or is this just a typo?
精彩评论