+ 1
How do we change the border style using java script of a div element written in HTML
7 odpowiedzi
+ 5
//Select your element using any selector function (querySelector, getElementById, etc):
let element = document.querySelector(".elem")
//And then change border style:
element.style.border = "1px solid #F00";
https://code.sololearn.com/WKZSK0LUsr7O/?ref=app
+ 5
mustafa raza you can just give an onclick to the div element, create the function, and in this function you can put the js code, where it changes the border. :)
+ 4
Hello mustafa raza,
You can get the elements (using document.querySelector or document.getElementById, ....), and using the '.style' and you can write your css code there.
If you want to change the border, for example, you can use '.style.border =... ', and so you can access to its style, using css properties etc. :)
+ 2
document.querySelector("div").borderStyle="groove";
+ 2
mustafa raza
Please don't mark your own answer as the best because in this case it doesn't answer the question.
+ 1
Thank you all of you
But what if i want to change border style when click on div element area.
0
Artem I did't know that tick is used for best answer i clicked it because i want my question on top so that i can get answer quickly.