点击多选框实现显示对应的图片


点击多选框实现显示对应的图片
<div class="am-list am-list-static am-myyuyue-list ">


 <div class="myyuyue-main-head">
       <span>免费报价</span>
       <p>40分钟前</p>

   </div>
   <span class="myyuyue-checkbox"  id="checkbox"> <input type="checkbox" name="myyuyue-checkbox" value=""> </span>
    <i id="myyuyue-foreman"><img src="Content/Image/img/myyuyue-foreman.png"></i>
   <div class="myyuyue-main-list">
        <p>预约单位:<span>装修公司</span></p>
        <p>申请人:<span>赵先生</span></p>
        <p>手机号码:<span>1350013500</span></p>
        <p>地址:<span>广东省广州市</span></p>
        <img src="Content/Image/img/myyuyue-complete.png">

   </div>

</div>
<div class="am-list am-list-static am-myyuyue-list ">


 <div class="myyuyue-main-head">
       <span>免费报价</span>
       <p>40分钟前</p>

   </div>
    <span class="myyuyue-checkbox"> <input type="checkbox" name="myyuyue-checkbox" value=""> </span>
   <i id="myyuyue-decoration"><img src="Content/Image/img/myyuyue-decoration.png"></i>
   <div class="myyuyue-main-list">
        <p>预约单位:<span>免费量房</span></p>
        <p>申请人:<span>赵先生</span></p>
        <p>手机号码:<span>1350013500</span></p>
        <p>地址:<span>广东省广州市</span></p>
         <img src="Content/Image/img/myyuyue-complete.png">

   </div>



   怎么这样实现不了
   $(":checkbox").each(function () { 
   var cheLength = document.getElementsByTagName("div");

     $(this).click(function () {
     for(var i=0; i<cheLength.length; i++)
          { 

         if ($(this).attr("checked") == "checked") { 
             $("cheLength img").show(); 
         } else { 
             $("cheLength img").hide(); 
         } 
       }
     }); 

 });

jquery 前端 JavaScript

我勒个来的 9 years, 2 months ago

$("cheLength img").show();
这句是什么?这样并获取不到图片啊

学会用浏览器下断点调试

战场原荡然 answered 9 years, 2 months ago

作一个循环吧,就是获取div动态id,我也不知道这样对不对,我要实现点击多个多选框显示对应的图片

popopjk answered 9 years, 2 months ago

Your Answer