简体   繁体   中英

Adjust border width of image using javascript

 var images = document.getElementById("facilityThumbNail").getElementsByTagName("img"); for (var i = 0; i < images.length; i++) { images[i].onmouseover = function() { this.style.cursor = 'hand'; this.style.borderColor = 'red'; // this.style.border ? ? ? ? ? } }
 <div id="facilityThumbNail"> <img src="https://unsplash.it/300/300" /> </div>

Just wondering if someone can please tell me how I can adjust the width of border for this image by advising what the attribute is? It's not width...

Do specify the borderStyle and borderWidth

 var images = document.getElementById("facilityThumbNail").getElementsByTagName("img"); for (var i = 0; i < images.length; i++) { images[i].onmouseover = function() { this.style.cursor = 'hand'; this.style.borderWidth = '10px'; this.style.borderStyle = 'solid'; this.style.borderColor = 'red'; } }
 <div id="facilityThumbNail"> <img src="https://unsplash.it/300/300" /> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM