php - Jquery event won't fire when element is displayed via mysql -
i have content fed in mysql that, when clicked should fire alert()... however, not working...
here code code fed in php/get_answers.php
<?php session_start(); ?> <?php require_once("../includes/include_all.php"); ?> <?php $answers = $question->get_answers_for_question($_get['id']); ?> <?php while($row = $answers->fetch_array()){ ?> <!-- answers here --> <div class = 'answer-row'> <div class = 'answer-side'> <div class = 'arrow-contain-answer' type = 'answer' id = 'arrow-up' answer-id = '<?php echo $row["id"]; ?>'></div> <div class = 'answer-votes-contain'> <?php echo $row['popularity']; ?> </div> <div class = 'arrow-contain-answer' id = 'arrow-down'answer-id = '<?php echo $row["id"]; ?>'></div> </div> <div class = 'answer-content'> <?php echo $row['content']; ?> </div> <div class = 'actions'> <a href = '#' class= 'add-comment' id = '<?php echo $row["id"]; ?>'> add comment </a> </div> </div> <?php } ?>
and here jquery on page displayed on:
$(".arrow-contain-answer").click(function(){ alert(); });
what want happen when clicks element class of 'arrow-contain-answer' event occur..
i think have had problems before when elements being 'fed' page via mysql/php.
$(document).on("click", ".arrow-contain-answer", function(){ alert(); });
try way dynamic added elements!
Comments
Post a Comment