Hello & Thanks:
I need help modifying css attribute .
I want to change the:
#bodyId {
font-family: Comic Sans MS;
background-image: url(background-image-01.jpg) ;
background-repeat: no-repeat;
background-size: cover;
}
Code runs with no errors , but no results .
Here is my code:
<html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--
https://www.w3schools.com/jsref/compman.gif
https://www.freeformatter.com/html-validator.html
-->
<style>
#bodyId {
font-family: Comic Sans MS;
background-image: url(background-image-01.jpg) ;
background-repeat: no-repeat;
background-size: cover;
}
.buttonPos {
position: absolute;
bottom: 10px;
left: 10px;
}
</style>
<script> </script>
</head>
<body id="bodyId" class="bodyClass" onload="resizeImage()">
<!--
background="background-image-01.jpg" background = "background-size = cover;">
<body onload="documentURL()">
-->
<br>
<script>
var bodyWidth ; var bodyHeight ; var imageWidth ; var imageHeight ; var img ;
window.addEventListener("resize", resizeImage());
function resizeImage() {
// alert("function resizeImage() {")
var targetBody = document.getElementById("bodyId");
// alert(targetBody) ;
bodyWidth = window.outerWidth ;
//alert("bodyWidth = " + bodyWidth + " window.outerWidth = " + window.outerWidth ) ;
bodyHeight = window.outerHeight ;
targetBody.setAttribute("width" , bodyWidth ) ;
targetBody.setAttribute("height" , bodyHeight ) ;
targetBody.setAttribute("background.img.width" , bodyWidth ) ;
targetBody.setAttribute("background.img.height" , bodyHeight ) ;
alert( 'bodyWidth = ' + bodyWidth + " bodyHeight = " + bodyHeight) ;
}
</script>
<script>
var imageCount = 0 ; var nextImage = "background-image-01.jpg" ;
var targetBg = document.getElementById("bodyId");
function changeImage() {
imageCount = imageCount + 1 ;
if (targetBg.hasAttribute("background")) {
document.getElementById("bodyId").style.background-image:url = "background-image-02.jpg";
x = document.getElementById("bodyId").style.background:url ;
console.log("x = " + x) ;
if (imageCount == 5) { imageCount = 0;}
}
</script>
<script>
/* holdArea :
imageCount = imageCount + 1 ;
elem = document.getElementById("myImage"); // element.style.backgroundColor = "red";
if (imageCount == 1) { if (targetBg.hasAttribute("background")) {
targetBg.setAttribute("background", "background-image-02.jpg"); } }
if (imageCount == 2) { if (targetBg.hasAttribute("background")) {
targetBg.setAttribute("background", "background-image-03.jpg"); } }
if (imageCount == 3) { if (targetBg.hasAttribute("background")) {
targetBg.setAttribute("background", "background-image-04.jpg"); } }
if (imageCount == 4) { if (targetBg.hasAttribute("background")) {
targetBg.setAttribute("background", "background-image-05.jpg"); } }
if (imageCount == 5) { if (targetBg.hasAttribute("background")) {
targetBg.setAttribute("background", "background-image-01.jpg"); } }
// targetBg.setAttribute("url","background-image-0"+((imageCount % 5)+1)+".jpg");
// targetBg.setAttribute("url","background-image-0"+((imageCount % 5)+1)+".jpg");
*/
</script>
<input type="button" class="buttonPos" onclick="changeImage()" value="Change Image">
</body>
</html>
Thanks for your help !