我有以下Jquery
switch (catSelected) {
case (""):
if (city == 1) {
cityName = "ROME";
$("#banner_img").css("background-image", "url(/images/HomePageBanner/rome_home1.jpg)");
$("#homePageGallery1 img").attr("src", "/images/TourListBanner/VatBannernew.png");
$("#homePageGallery1").find("a").attr("href", "/official-vatican-museum-partnership");
$("#homePageGallery1 img").show();
break;
}
else if(city == 0) {
cityName = "VATICAN";
$("#banner_img").css("background-image", "url(/images/TourListBanner/vatican1.jpg)");
$("#homePageGallery1 img").attr("src", "/images/TourListBanner/VatBannernew.png");
$("#homePageGallery1").find("a").attr("href", "/official-vatican-museum-partnership");
break;
}
更改类别时,它会更改顶部横幅图片。问题是已经有了一张图片,我不知道如何摆脱它或在它上面显示新图片。
更改类别后顶部横幅:
<img id="banner_img" class="resrc" style="height: auto; max-width: 1600px; width: 100%; background-image: url(http://localhost:45000/images/TourListBanner/colosseum-ancient-rome1.jpg);" data-src="http://app.resrc.it/o=85/http://www.x.com/images/listings/rome.jpg" alt="" data-resrc-width="1600" src="http://app.resrc.it/s=w1600,pd1/o=85/http://www.x.com/images/listings/rome.jpg">
我想我需要使用google jquery更改图片属性
答案 0 :(得分:0)
我知道了,$(this).attr(&#34; src&#34;,src);并删除那里的最新消息,它将图像放在图像上