First write good HTML code in PHP file to set the request header format text/html
And then I'm going to use jquery to define a container with an in-place code.
$ (function () {}) = = Window.onload
. SN-HEADER-BG is the container I used to put the code in.
My php file name is header.php placed in the data directory!
Execute the above code after the completion of a page header is out!
After loading I bound two functions in the header, but all failed because the corresponding DOM element was not found.
The root cause is that I did not load before the two functions have been executed to find the corresponding DOM element, all the error.
So how to solve, I found the relevant information on the Internet to find a solution!
The solution is that when the page is loaded, I execute the corresponding function to bind the event so that there is no error.
There will be no bug of event failure!
======================
Today is my first day to open Blog Park blog, this is my first blog, if there are any errors or better solutions, please advise!
How to use PHP and JS to dynamically load HTML elements and loaded HTML code binding event invalidation solution!