简体   繁体   中英

How to get value from HTML <div> by js

I want to get 1 from this div tag

<div class="h5p-footer-slide-count-current" title="Current slide" aria-hidden="true">1</div>
document.getElementsByClassName("h5p-footer-slide-count-current")[0].innerText

That should do it

Link javascript file and in javascript file do this

const div = document.getElementsByClassName("h5p-footer-slide-count-current")[0];

console.log(div.innerText); //your div value

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