Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why JavaScript method not get called?

I have this is html:

<script>
function decode(str) {
    return decodeURI(str);
}
</script>

<span>decode('Alma%20k%C3%B6rte%20di%C3%B3')</span>

Why it is not get called?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

HTML is a markup language and does not directly execute programmatic code as part of document content.

You can execute JS code in a <script> tag and use DOM methods to manipulate the document

<script>
function decode(str) {
    return decodeURI(str);
}
</script>

<span></span>

<script>
// locate the <span> element and update its `textContent` property
document.querySelector("span").textContent =
  decode('Alma%20k%C3%B6rte%20di%C3%B3')
</script>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading