-1
我是jquery的新手,我明天考試,我需要寫幾行代碼。我需要在它和圖像中創建一個帶有產品的變種。我需要調用圖像並將其添加到購物車。到目前爲止,我有這個: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)
});
});
這是很難說這是怎麼回事。一些HTML會有所幫助。 「validate_shoppingcart」是從哪裏調用的? – 2013-05-08 09:18:51
嗨大衛,沒有任何HTML本身...考官正在尋找jquery代碼...我不知道這是否有幫助 – user2304132 2013-05-08 10:38:55
以及對於初學者來說,它沒有太大的意義,有一個對象具有諸如'女士們「,那些應該是價值觀,而不是鑰匙。 – 2013-05-08 11:20:16