Change section tag's background image at runtime
Change <section> tag's background image at runtime. we assume that <section> tag's "back-img-url" attribute have the image link.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change <section> tag's background image at runtime. we assume that <section> tag's "back-img-url" attribute have the image link. </title>
</head>
<body>
Change <section> tag's background image at runtime. we assume that <section> tag's "back-img-url" attribute have the image link.
<section id="sec" class="image_main-banner-class module-container image-full-width-img text-text good-style fullimg-width-background "
back-img-url="IMAGE-URL">
Test Test Test<br/>Test Test Test<br/>Test Test Test<br/>Test Test Test<br/>Test Test Test<br/>Test Test Test<br/>Test Test Test<br/>
</section>
<script>
try {
let sec = document.getElementsByClassName("image_main-banner-class module-container image-full-width-img text-text good-style fullimg-width-background ");
let img=sec[0].getAttribute("back-img-url");
sec[0].style.backgroundImage = "url('"+img+"')";
} catch (err) { console.log(err); }
let tttt=0
if (window.screen.width < 500) {
tttt=5000;
} else {
tttt=2500;
}
</script>
</body>
</html>
0 comments:
Post a Comment