我对PHP , JS和HTML非常陌生 ,所以我希望你不要介意这个问题是否很微不足道。 所以我基本上有下面的代码, onlick会在一个单独的HTML文件中工作,但如果我把它放在一个PHP文件的回声中,或者把它放在一个PHP文件中的一个单独的html块中,它将不起作用。
button.html(这个工程)
<body> <p>Click the button to display the time.</p> <button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button> <p id="demo"> </p> </body> </html>这里是回声代码:
button.php(不起作用)
<?php .... .... echo " <input type ='button' value = 'Date' onclick = 'getElementById('demo')=Date();' /> <p id='demo'> </p> " ?>这是PHP文件中的HTML代码不起作用。
button.php(不起作用)
<?php> ?> <html> <body> <p>Click the button to display the time.</p> <button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button> <p id="demo"></p> </body> </html>任何帮助,将不胜感激!
I'm very new to PHP, JS, and HTML so I hope you don't mind if the question is very trivial. So I basically have the following code, the onlick would work in a separate HTML file but it will not work if I put this in an echo of a PHP file or put it in a separate html block inside a PHP file.
button.html (this works)
<body> <p>Click the button to display the time.</p> <button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button> <p id="demo"> </p> </body> </html>Here is the echo code:
button.php (doesn't work)
<?php .... .... echo " <input type ='button' value = 'Date' onclick = 'getElementById('demo')=Date();' /> <p id='demo'> </p> " ?>This is the HTML code inside PHP file that doesn't work.
button.php (doesn't work)
<?php> ?> <html> <body> <p>Click the button to display the time.</p> <button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button> <p id="demo"></p> </body> </html>Any help would be appreciated!
最满意答案
这是我已经试过希望这有助于
<!DOCTYPE html> <html> <body> <h1>My First JavaScript</h1> <button type="button" onclick="document.getElementById('date_time_button').innerHTML = Date()"> Click and see Date and Time.</button> <p id="date_time_button"></p> </body> </html>This is what i have tried Hope this helps
<!DOCTYPE html> <html> <body> <h1>My First JavaScript</h1> <button type="button" onclick="document.getElementById('date_time_button').innerHTML = Date()"> Click and see Date and Time.</button> <p id="date_time_button"></p> </body> </html>
更多推荐
HTML,PHP,button,电脑培训,计算机培训,IT培训"/> <meta name="description&q
发布评论