开发者

Passing an image through parameters, JQuery mobile

开发者 https://www.devze.com 2023-03-18 04:38 出处:网络
I have a simple JQuery Product list. When a user click an item, it opens a \"master page\" called details in which I pass the parameters like Brand, Description and Price.

I have a simple JQuery Product list. When a user click an item, it opens a "master page" called details in which I pass the parameters like Brand, Description and Price.

I'm trying to pass the image but I have no clue how I can do this. Any help appreciated. Thanks.

Heres how I pass the parameters :

 var productId = getParameterByName("productId", $(this).data("url"));
    $.mobile.pageLoading();
    var product = catalog.products[productId];

    $('#productDescription').html(product.description);
    $('#productBrand').html(product.brand);
    $('#productPrice').html(product.price);
    $('#productThumbnail').html(product.thumbnail);

    $.mobile.pageLoading(true);

Now if I can pass the Brand, description and price because they are text开发者_运维百科. But I dont know how to pass the image... I tried the following and it shows the URI of the image.

<div align="center">
            <label>Thumbnail</label>
            <label id="productThumbnail">Thumb</label>
        </div>


This should do the trick for you

$('#productThumbnail').html("<img src='"+product.thumbnail+"' alt='Thumbnail' />");


You asked this before: Adding images to a JSon array

You can't set #productThumbnail's html attribute, you need to set its src instead, using the image URI passed-in from product.thumbnail (mkilmanas's answer tells you how).

0

精彩评论

暂无评论...
验证码 换一张
取 消