📌  相关文章
📜  检查 div 是否包含背景图片 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:22.351000             🧑  作者: Mango

代码示例1
// HTML EXAMPLE
//Css example .element { background-image: url('http://www.todayifoundout.com/wp-content/uploads/2010/05/blue-sky.jpg'); width: 350px; height: 350px; } //your script JS var background = $('.element').css('background-image') if (background.indexOf("blue-sky.jpg") >= 0) { document.getElementById("element2").style.backgroundImage = "url(https://images.freeimages.com/images/premium/previews/2272/22721547-omg-face.jpg)"; }