Tuesday, September 7, 2021

How to access DOM object?

 We can access dom object by querySelector with id in css.

ex:document.querySelector('#score').textContent=100;

 We can access dom object by querySelector with class in css.

ex:document.querySelector('.score').textContent=100;

here ,.score is the class name in css.

if we want to set any html in any html then we use innerHtml.

ex:document.querySelector('.score').textContent='<em>'+100+'</em>';

No comments:

Post a Comment

Testing controller

------Controller------------- @RestController @RequestMapping("/items") public class ItemController {     private final ItemServic...