我想每次标题都应该包含一个新值

时间:2019-05-22 17:23:14

标签: javascript jquery json

$("#btn1").click(function(){
  $("#type1").html('<h2 id="heading">ab</h2>');
  $("#type1").css({"background-color":"white","font-size":"15px","text-align":"center","padding-top":"50px;","background-image":"",});
  $("")
  $.each(menuobj.pizza.veg,function(value,index)
  {       
    $("#heading").text(value+" "+ index);
  });

1 个答案:

答案 0 :(得分:-1)

var menu='{"pizza":{"veg":{"Name":"Veg-Pizza","Price":250},"nonveg":{"Name":"NonVeg-Pizza","price":350},"pizzamaina":{"Name":"Pizza-mania","Price":500}}}';
var menuobj=JSON.parse(menu);




$("#btn1").click(function(){
  $("#type1").html('<h2 id="heading"></h2>');

  $("#type1").css({"background-color":"white","font-size":"15px","text-align":"center","padding-top":"50px;","background-image":"",});

  $("")
  $.each(menuobj.pizza.veg,function(value,index)
  {       `enter code here`
    $("#heading").append(value+" "+ index);

});