L
L
lleballex2020-07-02 15:06:10
JavaScript
lleballex, 2020-07-02 15:06:10

Why doesn't JavaScript work on WordPress?

Urgently!!! The customer had to embed one element into the WP site. There styles, a script are just used. Well, I did everything as expected, I specifically used pure JS, without jQuery. Everything works for me, but he does not. Why? There was one piece of code, in which there are already scripts and styles, and html itself. I have never worked with WP. Help!!!

Maybe you need to write JS in the head, or throw it out in a separate file, or include something. I have never worked with WP

Here is the text of the error:

Uncaught ReferenceError: imtc_calculation is not defined
    at <anonymous>:1:1

Here is the code:
<script>
function imtc_calculation() {
           ...
}
</script>
<form onsubmit="imtc_calculation(); return false;">...</form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2020-07-02
@lleballex

https://jsfiddle.net/yarkov_aleksei/q7tcoans/

<script>
function imtc_calculation() {
    alert('imtc_calculation');
}
</script>
<button onclick="imtc_calculation();">CLICK</button>

Everything is working. Something you are not talking about.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question