根据另一个 div id 值显示 div
我正在使用一个购物车,它循环遍历数据库表中的产品选项 ID。对于每个选项,它都会创建一个标签并选择菜单,这些菜单被包装在一个 div 中,该 div 的 ID 值对于从数据库表中获取的选项行 ID 是唯一的。如果包装器 ID 值 == 特定 ID,我希望能够在选项 div 包装器上方显示带有自定义 html 的 div。
这是渲染的 div 包装器的样子,它包装了标签和选择菜单
<div class="form-field product-list-field clear" id="opt_2_5">
。生成此内容的 smarty 代码在这里。你看到 id=" 部分是插入 2 和 5 的地方。
{foreach name="product_options" from=$product_options item="po"}
{assign var="selected_variant" value=""}
<div class="form-field{if !$capture_options_vs_qty} product-list-field{/if} clear" id="opt_{$obj_prefix}{$id}_{$po.option_id}">
如果有人可以帮忙,我想写一个类似于下面的条件...(我完全编写了这个 if 语句,并且知道它不起作用任何帮助都将非常感谢使它工作)。我尝试了一个 smarty 语句,但我确信它可以在 jquery 中完成,以根据 value ==“opt_2_5”显示我的自定义 div,再次感谢任何帮助。
{if $id==2 && $po.option_id == 5 (Show div('#customIDofhiddendiv")}
I'm working with a shopping cart which loops through product option IDs in a db table. For each option it creates a label and select menu which are wrapped in a div who's ID value is unique to the option row id's it fetched from the db table. I'd like to be able to display a div with custom html above the option div wrapper if the wrapper ID value is == a specific ID.
Here is what a rendered div wrapper looks like which wraps the label and select menu
<div class="form-field product-list-field clear" id="opt_2_5">
The smarty code which generates this is here. You see the id=" part is where it's inserting the 2 and 5.
{foreach name="product_options" from=$product_options item="po"}
{assign var="selected_variant" value=""}
<div class="form-field{if !$capture_options_vs_qty} product-list-field{/if} clear" id="opt_{$obj_prefix}{$id}_{$po.option_id}">
If someone could help i'd like to write a condition similar to the below... (I totally made this if statement up and know it doesn't work. Any help would be really appreciated to make it work). I tried a smarty statement but i'm sure it can be done in jquery to display my custom div based on value == "opt_2_5" any help again is appreciated thanks
{if $id==2 && $po.option_id == 5 (Show div('#customIDofhiddendiv")}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不会为您编写 jQuery,但对于
Show div('#customIDofhiddendiv")
,您可以使用display
/visibility
元素的属性,使其根据您想要的任何条件显示/消失。 rel="nofollow">http://www.w3schools.com/css/css_display_visibility.aspI'm not going to write the jQuery for you, but for
Show div('#customIDofhiddendiv")
, you can use thedisplay
/visibility
attributes for your element to make it show up/disappear according to whatever conditions you want. http://www.w3schools.com/css/css_display_visibility.asp