Javascript jQuery选中按钮,可以';无法获取要警报的属性

Javascript jQuery选中按钮,可以';无法获取要警报的属性,javascript,php,jquery,select,this,Javascript,Php,Jquery,Select,This,我在回显行,希望删除它们或像竖起大拇指一样增加它们。。。我似乎无法单独识别行 这是我附带的jquery源代码 <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> javascript web控制台中没有错误 这是我试图通过测试['clicked']实现的click函数: <script type="text/javascript">

我在回显行,希望删除它们或像竖起大拇指一样增加它们。。。我似乎无法单独识别行

这是我附带的jquery源代码

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

javascript web控制台中没有错误

这是我试图通过测试['clicked']实现的click函数:

<script type="text/javascript">
$(":button").click(function() {
var selectedId = $( this ).attr(id);
alert(selectedId);
alert('clicked');
});
</script>

$(“:按钮”)。单击(函数(){
var selectedId=$(this).attr(id);
警报(选择EDID);
警报(“点击”);
});
这些是我重复的行:

<?php

require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR.'dbconnect.php');

$link = new mysqli("$servername", "$username", "$password", "$dbname");

$query = "SELECT COUNT(*) FROM entries";

if ($result = $link->query($query)) {


    /* fetch object array */
    while ($row = $result->fetch_row()) {
        if($row[0]==0){
        echo "There are no entries.";
        }else {
        $query2 = "SELECT id,saying,date,thumbs_up,comments FROM entries ORDER by ID ASC ";

if (($result = $link->query($query2))) {
    /* fetch object array */
    while ($row = $result->fetch_row()) {

       echo 
       '<div class="primary-container" align="center">'.
       '<div class="entry-container" align="center">'.
       $row[1]." ".
       '</div>'.
       '<div class="bird" align="center">'.
       'Bird Up!'.
       '</div>'.
       '<div class="birdups" align="center">'.
       $row[3].
       '</div>'.
       '<div class="thumbup" align="center">'.
       '<button name="increment" class="button" id="'.$row[0].'">'.
       '<img src="bird_up.png" width="100%" height="auto" alt="bird up thumbs up like equivalent thumbnail">'.
       '</button>'.
       '</div>'.
       '</div>'.
       '<br>'
       ;

    }
    }
        }
    }

    /* free result set */
    $result->close();

}

?>

对新添加的html元素使用事件委派。你错过了id的单引号。我希望它能解决你的问题,谢谢

$(document).on("click" , ".button" , function() {
  var selectedId = $(this).attr('id');
  alert(selectedId);
});

对新添加的html元素使用事件委派。你错过了id的单引号。我希望它能解决你的问题,谢谢

$(document).on("click" , ".button" , function() {
  var selectedId = $(this).attr('id');
  alert(selectedId);
});

对新添加的html元素使用事件委派。你错过了id的单引号。我希望它能解决你的问题,谢谢

$(document).on("click" , ".button" , function() {
  var selectedId = $(this).attr('id');
  alert(selectedId);
});

对新添加的html元素使用事件委派。你错过了id的单引号。我希望它能解决你的问题,谢谢

$(document).on("click" , ".button" , function() {
  var selectedId = $(this).attr('id');
  alert(selectedId);
});

哇!太完美了!这是我问这个问题的第三篇帖子哈哈。感谢JqueryKing值得一提的是,您在
id
周围添加了引号(这看起来像是实际问题)。@ArturFilipiak-感谢您的通知。太完美了!这是我问这个问题的第三篇帖子哈哈。感谢JqueryKing值得一提的是,您在
id
周围添加了引号(这看起来像是实际问题)。@ArturFilipiak-感谢您的通知。太完美了!这是我问这个问题的第三篇帖子哈哈。感谢JqueryKing值得一提的是,您在
id
周围添加了引号(这看起来像是实际问题)。@ArturFilipiak-感谢您的通知。太完美了!这是我问这个问题的第三篇帖子哈哈。感谢JqueryKing值得一提的是,您在
id
周围添加了引号(这看起来像是实际问题)。@ArturFilipiak-感谢您的通知