<script type="text/javascript">
function choose_customer(){
$('[nctype="btn_add_customer"]').each(function(index){
if(!$(this).attr('data-customer_id')){
$('[sort='+index+']').removeClass('ncsc-btn-green');
//alert($(this).parent('li').html());
$('[sort='+index+'] > span').text('<?php echo $lang['choose_already'];?>');
}else{
//alert($(this).parent('li').html());
$('[sort='+index+'] > span').text('<?php echo $lang['choose_customer'];?>');
}
});
}
$(function(){choose_customer();});
</script>
<!--
//$key 是遍历的键值,代码段:<?php foreach($output['store_customer_list'] as $key=>$val){?>
//使用each将相同的<a>遍历出来, .each() 描述: 遍历一个jQuery对象,为每个匹配元素执行一个函数。
//属性 data-customer_id 为空是去掉<a>部分 class ,同时给 span 添加字段
//属性data-customer_id 不为空 只给 span 添加字段
-->
<li><a nctype="btn_add_customer" sort="<?php echo $key;?>" data-customer_id="<?php echo $val['sc_customer_id'];?>" href="javascript:void(0);" class="ncsc-btn-mini ncsc-btn-green"><i class="icon-ok-circle "></i><span><?php echo $key;?></span></a></li>
jquery 使用each 遍历标签元素,修改标签内容
最新推荐文章于 2025-06-27 10:44:03 发布