点击按钮编写内容

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangyanxin928/article/details/53694006
<ul class="recipient of pb20">
    <li class="jb_yellow">
        <p>李晓明 <span class="fr" onclick="editItemPrice(this)">编辑</span></p>
        <p class="ro">北京市昌平区回龙观镇龙域北街金域国际中心A座1210室</p>
        <p>1891****044</p>
    </li>

</ul>

<script>
    //店铺保养项目价格修改
    function editItemPrice(item){
        var id = $(item).attr("id");
        if($(item).text()=="编辑"){
            var item_price = $(item).parent().parent().find(".ro")[0].innerText;

            $(item).parent().parent().find(".ro").empty();
            $(item).parent().parent().find(".ro").append("<textarea type='text' class='bdda w200' id='price_input_"+ id +"' value='"+item_price+"'>"+item_price+"</textarea>");
            $(item).text("保存");
            $(item).attr("class","fr");
        }else if($(item).text()=="保存"){
            var item_price = $("#price_input_"+id).val();
            if(item_price==""|| null){
                alert("请输入正确的收货地址");
                return;
            }
///这是之前的请求。需要修改
//            $.ajax({
//                url : "${ctx}/api/b2b2c/storeApi!editStoreRepairItem.do?id="+id+"&item_price="+item_price+"&repair_price="+repair_price,
//                type : "POST",
//                dataType : "json",
//                success : function(result){
//                    alert(result.message);
//                    $(item).parent().parent().find(".ro").empty();
//                    $(item).parent().parent().find(".ro").append(item_price);
//                    $(item).text("编辑");
//                    $(item).attr("class","btn_too btn_submit");
//                    //location.reload();
//                },
//                error : function(){
//                    alert("请求出错");
//                }
//            });
        }
    }
</script>

猜你喜欢

转载自blog.csdn.net/wangyanxin928/article/details/53694006