您好我正在尝试创建一个打开包含类的对话框的函数。这些类的倍数,所以我希望它们独立开放。
这是我目前的JS,它位于document.ready
中$('.search_package_items').hide();
$('.packageicon').each(function() {
$.data(this, 'dialog',
$(this).next('.search_package_items').dialog({
autoOpen: false,
modal: true,
width: 300,
height: 250,
buttons: {
"Save": function() {
$(this).dialog( "close" );
},
Cancel: function() {
$(this).dialog( "close" );
}
}
})
);
}).click(function() {
$.data(this, 'dialog').dialog('open');
return false;
})
此外,我不确定这是否是正确的jquery,但这是我要包括的那个
<script src="//code.jquery.com/jquery- 1.6.1.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
上工作的网站
在我尝试之前
$(this).next(".search_package_items)"
但经过一些研究我知道,因为.dialog()将它包含在对话框元素中的内容移动到结尾,所以.next()将不再找到它,所以我尝试了上面的类,但仍然没有。
编辑:
请注意这是php生成的,所以我只是从页面源信息中获取它
<button class="packageicon" style="font-size: 10px; display:blockclear:both;">
<b>This package includes:</b>
</button>
<div align="left" style="margin-top:10px;">
<table class="search_package_items" cellspacing="0"><tr><td align="center">
<div style="height:80px;" align="center">
<img src="http://img2.appliancesconnection.com/product/75x75/be79b8fbb0ba51ae1c7e969dcd327f1d.jpg" alt="Amana ASD2575BRS">
</div>
<hr style="color:#DDDDDD">
<div style="width:110px;">
<span class="search_package_items_qty">1 x </span>
<span class="search_package_items_details"><a href="http://m.appliancesconnection.com/amana-asd2575brs-i320797.html">Amana<br>ASD2575BRS</a></span>
</div>
</td>
<td align="center"><div style="height:80px;" align="center">
<img src="http://img2.appliancesconnection.com/product/75x75/fdb06def4b1abd23dca52abdd0fddb4e.jpg" alt="Amana AER5330BAS"></div><hr style="color:#DDDDDD">
<div style="width:110px;">
<span class="search_package_items_qty">1 x </span>
<span class="search_package_items_details"><a href="http://m.appliancesconnection.com/amana-aer5330bas-i336463.html">Amana<br>AER5330BAS</a></span>
</div>
</td>
<td align="center">
<div style="height:80px;" align="center">
<img src="http://img2.appliancesconnection.com/product/75x75/37dcc721e72531f50a3daff61760d2f4.jpg" alt="Amana ADB1100AWS">
</div>
<hr style="color:#DDDDDD">
<div style="width:110px;">
<span class="search_package_items_qty">1 x </span>
<span class="search_package_items_details"><a href="http://m.appliancesconnection.com/amana-adb1100aws-i313702.html">Amana<br>ADB1100AWS</a></span>
</div>
</td>
<td align="center"><div style="height:80px;" align="center"><img src="http://img2.appliancesconnection.com/product/75x75/20c252a2d35dd0059a6af27c58d1941c.jpg" alt="Amana AMV2175CS">
</div>
<hr style="color:#DDDDDD">
<div style="width:110px;">
<span class="search_package_items_qty">1 x </span>
<span class="search_package_items_details"><a href="http://m.appliancesconnection.com/amana-amv2175cs-i336292.html">Amana<br>AMV2175CS</a></span>
</div>
</td>
</tr>
</table>
</div>
EDIT2:如果有人想要的话,这就是小提琴:http://jsfiddle.net/Jnewguy/tztL1v3u/5/
有什么想法吗?