Use jquery to change the color of button according to the value obtained in each loop

     <volist name="list" id="v" key="k">
            <div class="shdz_list">             
                <div class="shdz_top">
                

{$v.name}

<span>{$v.phone}</span> <!-- style=" background: -sharpf17f17; border:1px solid -sharpf17f17; color: -sharpfff;" --> <!-- <button class="ischeck" val="{$v["id"]}">{$v.status}</button> --> <button class="ischeck" val="{$v["id"]}">{$v.status}</button> </div> <div class="shdz_w">{$v.province} {$v.city} {$v.area} {$v.address}</div> <div class="shdz_bottom"> <!-- <input id="{$v.ifdefault}" type="radio" name="item" value="" checked="checked"> <label for="1"></label> -->

<a href="{:U("editaddress",array("id"=>$v["id"]))}" style=" background:url(/Public/images/bj_1.png) no-repeat center left;background-size:18px; margin-right: 3%;"></a> <a class="dellink" val="{$v["id"]}" href="javascript:;" style=" background:url(/Public/images/sc.png) no-repeat center left;background-size:18px; margin-left: 3%;"></a>

</div> </div> </volist> $(function() { $(".ischeck").val(); // console.log($(".ischeck").text()); $(".ischeck").each(function(){ ass = $(".ischeck").text(); if (val == ""){ var $pat = $(this).parent(); $pat.css("background","blue") }else if(val ==""){ var $pat = $(this).parent(); $pat.css("background","-sharpf3f3f3") } console.log(val); // alert(ass); // }); });
May.09,2022

well, man, excuse my ignorance, are you sure this is jQuery? Hope to post the complete code

Menu