checking for dynamic content - ajax()
Okay I have a blank html page with the following in the head:
- $(document).ready(function () {
- $.ajax({
- url: 'include.html',
- success: function(data){
- $('body').html(data);
- }});
-
- if ($('#load').length) {
- alert('Hello');
- }
-
- });
And a file called include.html with the following:
- <p id="load">Hello</p>
The idea is to dynamically load the include (which is working fine) and then if it has loaded create an alert 'Hello' (which is not working).
My question is why isn't this working? I appreciate that it's probably because it's been loaded dynamically and if ($('#load').length) is not checking dynamic content - but how would I amend the if statement to also check dynamic content?
Thanks!