-1

我是 jquery 的新手,明天我有一个考试,我需要写几行代码。我需要创建一个包含产品和图像的变量。我需要调用图像并将其添加到购物车中。到目前为止,我有这个:

可以反馈将不胜感激!!!

      $(document).ready(function() { // function contains everything, set to load when      page is ready

    var product;            // 3 global variables rest of function can use
    var source;
    var shoppingcart;

    var product = {                               //an array of products
    shoes: [
    {ladies: "High Heels", qty: 5},
    {mens: "runners", qty: 10},
    {childrens: "slippers", qty: 6},
    ]
     };

     var shoppingcart = ???????????

     var source = $("#myImage").attr("src"); //images are stored here

      $("#product").on("click", display_product);

      var validate_shoppingcart = (function() {
      shoppingcart.push($this)
    });

      OR SHOULD IT BE

  var validate_shoppingcart = (function (e){      // I am  Trying to call the image 
     $("#product").attr($this)
     });

      });
4

1 回答 1

0
var products = {
    shoes: [
        {category: 'ladies', model: 'High Heels', qty: 10},
        {category: 'mens', model: 'Runners', qty: 5},
        {category: 'children', model: 'Slippers', qty: 6},
    ]
}

这样的事情会更有意义

于 2013-05-08T11:23:10.690 回答