Answer the question
In order to leave comments, you need to log in
How to properly integrate JS and HTML?
As it is more correct, it is "beautiful" to write JS code. Using jQuery as an example.
So:<button id="click">Кнопка</button>
$('document').ready(function(){
$('#click').click(function(){
console.log(123);
})
})
<button onclick="click()">Кнопка</button>
function click(){
console.log(123);
}
Answer the question
In order to leave comments, you need to log in
in fact, depending on how you write, here, apparently, you have the most primitive layout option, for it inline events (onclick="click()") are used only as a last resort, since they are not obvious in the code.
and yet you do not apply an alert, this is a blocking operation.
But in the second option - there will be no "doubling / x4 / x8 / ..." listeners and "why the code does not work when I use Ajax".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question