How to pass parameters in this js?


< html >
< head >
< script >
function myFunction (data)
{
alert ("data");
}
< / script >
< / head >

< body >
< button onclick= "myFunction ()" > Click here < / button >
< / body >
< / html >

this js is written in the html code, and I"m going to pass the data into the js function in the html code from the imported js file.
what should I do? Due to special requirements, this js should be written in html, but the data does not know how to transfer from the external js.
Thank you.

Jul.15,2021

this depends on the specific situation.
if there is only a limited amount of data sent from js, it can be encapsulated as a parameterless call entry

. In addition, I think the problem is that since you are going to write HTML, where does your dynamic change come from? Whether it can be written to a global variable, which can also be called without parameters by accessing the global variable.

Menu