西西木科技丨Shopify开发机构 2022-09-22 18:05 采纳率: 96.4%
浏览 37
已结题

根据显示的div更改img src

根据显示的div更改img src

根据显示的.product-boxx,切换相应的step4img对应的src
因为.product-boxx一共有7个,所以最终的结果会有28款,就是需要切换28张图


<div class="container" id="finalform" style="display: flex;">
    <img src="//cdn.shopify.com/s/files/1/0501/9775/8119/files/Banner.jpg?v=1663254286" id="step4img" class=" ls-is-cached lazyloaded">

    <div class="flexboxxxxx">
        <botton id="finaltopback" class="custombtn0">back</botton>
        <botton id="fianlatc" class="custombtn1" onclick="adddd()">Add To Cart</botton> <a href=""
            class="custombtn2">Start Over</a>
    </div>
    <div class="product-boxx" id="product-laptop" style="display:none;">
        <p class="toptext">PRIMARY MOUNT OF YOUR CHOICE</p>
        <div class="product-info"> 
            <a href=" " target="_blank"> 
                <span class="producttitle">Single Arm Laptop Stand(DZ)</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$79.99 USD</p>
    <form method="post" action="/cart/add">
        <input type="hidden" name="id" value="42749446029479">
        <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
    </form>
    </div>

    <div class="product-boxx" id="product-monitor" style="display:none;">
        <p class="toptext">PRIMARY MOUNT OF YOUR CHOICE</p>
        <div class="product-info">
            <a href=" " target="_blank">
                <span class="producttitle">Single Arm Monitor Stand(DZ)</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$69.99 USD</p>
        <form method="post" action="/cart/add">
            <input type="hidden" name="id" value="42749450616999">
            <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
        </form>
    </div>
    <div class="product-boxx" id="product-lapmon" style="">
        <p class="toptext">PRIMARY MOUNT OF YOUR CHOICE</p>
        <div class="product-info">
            <a href=" " target="_blank">
                <span class="producttitle">Dual Arm Stand for Laptop and Monitor(DZ)</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$99.99 USD</p>
        <form method="post" action="/cart/add">
            <input type="hidden" name="id" value="42749457858727">
            <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
        </form>
    </div>
    <div class="product-boxx" id="product-monitor2" style="display:none;">
        <p class="toptext">PRIMARY MOUNT OF YOUR CHOICE</p>
        <div class="product-info">
            <a href=" " target="_blank">
                <span class="producttitle">Dual Arm Monitor Stand(DZ)</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$89.99 USD</p>
        <form method="post" action="/cart/add">
            <input type="hidden" name="id" value="42749461004455">
            <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
        </form>
    </div>
    <div class="product-boxx" id="product-light" style="">
        <p class="toptext">RING LIGHT OF YOUR CHOICE</p>
        <div class="product-info">
            <a href=" " target="_blank">
                <span class="producttitle">12“ Ring Light Set with Arm (DZ)</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$70.00 USD</p>
        <form method="post" action="/cart/add">
            <input type="hidden" name="id" value="42749468639399">
            <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
        </form>
    </div>
    <div class="product-boxx" id="product-pad" style="">
        <p class="toptext">TABLET HOLDER OF YOUR CHOICE</p>
        <div class="product-info">
            <a href=" " target="_blank">
                <span class="producttitle">Tablet Holder with Arm(DZ)</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$39.99 USD</p>
        <form method="post" action="/cart/add">
            <input type="hidden" name="id" value="42749478699175">
            <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
        </form>
    </div>
    <div class="product-boxx" id="product-micro" style="display:none;">
        <p class="toptext">MICROPHONE ARM OF YOUR CHOICE</p>
        <div class="product-info">
            <a href=" " target="_blank">
                <span class="producttitle">Microphone Mount with Parallel Connector</span>
            </a>
            <p class="productdes"></p>
        </div>
        <p class="productquality">x 1</p>
        <p class="productprice">$39.99 USD</p>
        <form method="post" action="/cart/add">
            <input type="hidden" name="id" value="42749487186087">
            <input type="submit" value="Add to cart" class="atcbtn" style="opacity: 0;">
        </form>
    </div>
    <hr align="center" width="100%" style="background:#000;height:1px;">
    <div class="bottombox">
        <div class="bottonbox">
            <botton id="step4-back" class="custombtn0">back</botton> <a href="/cart" class="custombtn1"
                target="_blank">View Carts</a> <a href="" class="custombtn2">Start Over</a>
        </div>
        <div class="pricebox">
            <p class="total">Estimated total: $</p> <input type="text" id="finalprice" disabled="">
            <p class="totaltext">Estimated total does not include freight. The freight will be informed after you
                provide the address.</p>
        </div>
    </div>

</div>
  • 写回答

2条回答 默认 最新

  • CSDN专家-showbo 2022-09-22 18:24
    关注

    根据步骤2得到图片容器设置下步骤4的图片就行,改下setSum这个函数,如下

    
    
        function setSum() {
    /////图片设置
            var step1option = $("input[name='equipment']:checked").val(), stepId;
            switch (step1option) {
                case 'laptop': stepId = 'step2-laptop'; break;
                case 'monitor': stepId = 'step2-monitor'; break;
                case 'laptopmonitor': stepId = 'step2-lapmoni'; break;
                case 'monitormonitor': stepId = 'step2-monitor2'; break;
            }
            var src = $('#' + stepId).find('img.accessories-img').attr('src');
            console.log(src)
            $('#step4img').attr('src',src)
    
    /////图片设置
    
    
    
            var sum = 0;
            $('#finalform .product-boxx:visible p.productprice').each(function () {
                sum += parseFloat(this.innerText.substring(1));
            });
            sum = sum.toFixed(2);//保留2位小数,防止浮点数计算精度丢失
            $('#finalprice').val(sum)
    
    
            $('#fianlatc').unbind().click(async function () {
                var btns = $('#finalform .product-boxx:visible input.atcbtn');
                for (var i = 0; i < btns.length; i++) {
                    //await控制循序请求,2秒点一个按钮
                    await clickButton(btns.eq(i))
                }
            })
    
        }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月1日
  • 已采纳回答 9月23日
  • 创建了问题 9月22日

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。