點擊按鈕編寫內容

<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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章