How to use PHP and JS to dynamically load HTML elements and loaded HTML code binding event invalidation solution!

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.