简体   繁体   中英

jQuery .click not being recognised

I cannot figure out what is up with this section of code as follows:

$(document).ready(function(){
    $('#testimonialContent').load('http://www.1.co.uk/wp-content/themes/1/testimonialPull.php');
  $('#nextQu').click(function(){
        alert(".");
    return false;
  });
});

I am not getting the alerted message when I should be. I dont think I have made any syntaxial errors?

HTML:

<?php
    require_once('../../../wp-blog-header.php');
    header('HTTP/1.1 200 OK');
?>
<br /><br /><br /><br /><br /><img id="quoteOne" src="http://www.1.co.uk/wp-content/themes/1/images/quote1.png">
    <span><?php
        query_posts(array(
            'cat' => 39,
            'order' => 'ASC', // ASC
            'orderby' => 'rand',
            'showposts' => 1,
            ));
        $wp_query->is_archive = true; $wp_query->is_home = false;
        if (have_posts()) : while (have_posts()) : the_post();
        the_content();
        endwhile; endif;


    ?>
    <span id="nextQu">NEXT QUOTE</span>
    </span>

Try using delegation:

$('#testimonialContent').on('click','#nextQu',function(){
        alert(".");
    return false;
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM