![](/img/trans.png)
[英]How do I get a value from dynamically created form in a dropdown menu using PHP?
[英]How do I build a dropdown menu from a dynamically created nested unordered list?
我有一个无序列表,它是在嵌套嵌套无序列表的循环中动态生成的。 我只想显示<h4> nested list name </h4>
,然后单击该子列表。
这是创建列表的整个代码块:
<ul class="faceted-menu">
<?php
// Loop through faceted menus
while(shopp('collection.facet-menus')) :
// Skip menus with no options
if ( ! shopp('collection.facet-menu-has-options')) continue;
?>
<li>
<h4 style="color: #303030;"><?php
// current facet filter name
shopp('collection.facet-name'); ?></h4>
<ul class="facet-option" style="display:none;">
<?php
// Loop through filter options for this faceted menu
while(shopp('collection.facet-options')) : ?>
<li>
<a href="<?php
// toggle url for current filter option
esc_url(shopp('collection.facet-option-link')); ?>"><?php
// the full label of the facet filter option
shopp('collection.facet-option-label'); ?></a> (<span class="count"><?php
// the number of products sharing this facet
shopp('collection.facet-option-count'); ?></span>)
</li>
<?php endwhile; ?>
</ul>
</li>
<?php endwhile; ?>
</ul>
这是我尝试过的两个jQuery脚本,但都无法正常工作:
$("ul.faceted-menu li").click(function(event) {
$(this).find("ul.facet-option").removeAttr('style');
});
和:
$("ul.faceted-menu li").live('click', function() {
$(this).find("ul.facet-option").removeAttr('style');
});
我愿意接受任何建议。
尝试以下操作:单击菜单li时,它将显示.facet-option。
$("ul.faceted-menu li").click(function() {
$(".facet-option", this).show();
});
如果您需要隐藏其他菜单,请单击
$("ul.faceted-menu li").click(function() {
$(".facet-option").hide();
$(".facet-option", this).show();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.