我有一些從mysql提供的內容,點擊時應該發出警報()... 但是,這不起作用...當元素通過mysql顯示時,jquery事件不會觸發
這裏是我是從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()){ ?>
<!-- ALL 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 } ?>
和這裏的代碼代碼,它顯示在頁面上的jQuery:
$(".arrow-contain-answer").click(function(){
alert();
});
我想要什麼至發生的時候,有人點擊與'箭頭包含答案'類的元素將發生一個事件..
我想我有問題之前元素是通過mysql/php「喂」到頁面。
你真的具有的屬性和它們的值之間的空間?這是行不通的。 – AndrewR 2013-04-04 08:10:47
nope,當我複製並粘貼我的格式時,所有的時髦...我試圖儘可能清除它 – 2013-04-04 08:11:22
定義html屬性時,不要用空格包圍等號'='。此外,使用雙引號這樣的屬性:'class =「arrow-containing-answer」'而不是'class ='arrow-containing-answer'' – 2013-04-04 08:11:39