Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 删除最后一个附加_Javascript_Html_Jquery_Jquery Mobile - Fatal编程技术网

Javascript 删除最后一个附加

Javascript 删除最后一个附加,javascript,html,jquery,jquery-mobile,Javascript,Html,Jquery,Jquery Mobile,我想在单击“上一步”按钮时删除最后一个附加。但是当我再次选择追加时,最后一个追加仍然存在 这是我附加的代码。其工作: $(req.responseText).find('ItemName').each(function () { ItemNameArr[ItName] = $(this).text(); ItName++; }) $(req.responseText).find('ItemQty').each(function () {

我想在单击“上一步”按钮时删除最后一个附加。但是当我再次选择追加时,最后一个追加仍然存在

这是我附加的代码。其工作:

$(req.responseText).find('ItemName').each(function () {
    ItemNameArr[ItName] = $(this).text();
    ItName++;
})                  

$(req.responseText).find('ItemQty').each(function () {
    ItemQtyArr[ItQty] = $(this).text();
    ItQty++;
})         

$(req.responseText).find('ItemUnit').each(function () {
    ItemUnitArr[ItUn] = $(this).text();
    ItUn++;
})

for (var a = 0; a < ItemNameArr.length; a++) {
   //$contentDt = $('<p><h6> ' + ItemQtyArr[a] + " " + ItemUnitArr[a] + " " + ItemNameArr[a] + '</h6></p>');                              
    $('#Ingredients').append('<p><h6> ' + ItemQtyArr[a] + " " + ItemUnitArr[a] + " " + ItemNameArr[a] + '</h6></p>')
    $('#Ingredients').fieldcontain('refresh')
 }
我的代码是在html中附加的

<div data-role="fieldcontain" id="Ingredients">    <!--Ingridients-->

 </div>    

   });  

});  

您可以使用下面的代码来完成

$('#Ingredients p:last').remove();

您可以使用下面的代码来完成

$('#Ingredients p:last').remove();
使用此代码

$('#Ingredients p:last').remove();
解释

#
id选择器的推荐人

$('#配料p)
在id为配料的元素中查找p标记

$(“#配料p:last”)
选择元素中id为配料的最后一个p标记

.remove()
函数将其从页面中删除。

使用此代码

$('#Ingredients p:last').remove();
解释

#
id选择器的推荐人

$('#配料p)
在id为配料的元素中查找p标记

$(“#配料p:last”)
选择元素中id为配料的最后一个p标记


.remove()
函数将其从页面中删除。

问题在于返回按钮代码(单击事件)

它将是——

$("html").on('click','#btnBack',function(){

      // your code

      // for remove last p element within #Ingredients
      $('#Ingredients p:last').remove();
});

问题在于返回按钮代码(单击事件)

它将是——

$("html").on('click','#btnBack',function(){

      // your code

      // for remove last p element within #Ingredients
      $('#Ingredients p:last').remove();
});

$('p').last().remove()?您需要向我们提供页面布局。下面的所有答案都是正确的,您只是没有在适当的时候使用它们。是的,请提供完整的页面:)$('p')。最后()。删除()?您需要向我们提供您的页面布局。下面的所有答案都是正确的,您只是没有在适当的时候使用它们。是的,请提供完整的页面:)仍然获得最后一个附加,先生..我将您的代码放在后面按钮将获得最后一个附加,先生..我将您的代码放在后面按钮