hello,
I have this script work well, i have on m page i want append attr and style to its but the tag append and attr not working together
please advise how to do that, append and attr works with img but with div its not working.
function Product_PreSetting2(pagename) {
// $('[id*=dvfirstlevelcategory]').empty();
$.ajax({
type: "POST",
cache: false, // disable caching
url: "/WebMethods/GH_WebMethods.asmx/get_product_setting?" + randomString,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ pagename: pagename }),
success: function (data) {
var itemsHtml = "";
// set attributes or content to the new div
$.each(data.d, function (index, item) {
if (item.ShowTitle == true) {
$('#lblproducthometitle').append(item.Title);
}
$('#dvproducthomebox').attr("class", item.productcountcss);
$('#dvproducthomebox').attr("style", item.backgrouncolorcss);
if (item.ShowBanner == true) {
$('#imgproducthomeboximage').append(
$('<img>').attr('src', item.Banner).attr('alt', item.Title)
);
}
});
},
error: function (response) {
alert(response.responseText);
}
});
}