Javascript 在单击jquery时选择某些按钮值

Javascript 在单击jquery时选择某些按钮值,javascript,jquery,ajax,Javascript,Jquery,Ajax,在预订页面的“查看/编辑”部分,我有一个通过AJAX生成的表,其中包含预订时间、房间号、日期,还有一个“编辑预订”,该表有一个按钮,该按钮的值从0开始,并根据单击时生成的行数递增,我可以通过值编号将该行作为目标,以获取要发送到SQL语句的正确字段 <? php function usersBookings($group) { $q = $this->connection->prepare("SELECT `timeslot`.`shortDesc`, `boo

在预订页面的“查看/编辑”部分,我有一个通过AJAX生成的表,其中包含预订时间、房间号、日期,还有一个“编辑预订”,该表有一个按钮,该按钮的值从0开始,并根据单击时生成的行数递增,我可以通过值编号将该行作为目标,以获取要发送到SQL语句的正确字段

<? php 
function usersBookings($group) {
        $q = $this->connection->prepare("SELECT `timeslot`.`shortDesc`, `booking`.`room_ID`, `booking`.`date` FROM `booking` JOIN `timeslot` ON `timeslot`.`blockID` = `booking`.`block_ID` 
        WHERE `team_name` LIKE ? ORDER BY `booking`.`date` ASC");
        $q->execute(Array($group));
        $str =  "<table id='userTable' style='width:80%'>
                    <tr>
                        <th style='border-bottom:1px solid black'>Booking Time</th>
                        <th style='border-bottom:1px solid black'>Room Number</th>
                        <th style='border-bottom:1px solid black'>Date</th>
                        <th style='border-bottom:1px solid black'>Edit Booking</th>
                    </tr>";
            $counter = 0;
            while ($result = $q->fetch()) {
                    $str .= "<tr>
                        <td>$result[0]</td>
                        <td>$result[1]</td>
                        <td>$result[2]</td>
                        <td><button class='edit_btn' value='$counter'>Edit</button></td>
                    </tr>";

                $counter++;         
            }

            $str .= "</table>";
            return $str;
    }
?>

您可以使用
。单击
事件并获取

$('#userTable button').click(function(){
     $buttonNo = $(this).val(); 
     ...
});

您可以使用
。单击
事件并获取

$('#userTable button').click(function(){
     $buttonNo = $(this).val(); 
     ...
});

您可以使用
。单击
事件并获取

$('#userTable button').click(function(){
     $buttonNo = $(this).val(); 
     ...
});

您可以使用
。单击
事件并获取

$('#userTable button').click(function(){
     $buttonNo = $(this).val(); 
     ...
});

最好是添加一些注释,而不仅仅是将代码扔出去。最好是添加一些注释,而不仅仅是将代码扔出去。最好是添加一些注释,而不仅仅是将代码扔出去。最好是添加一些注释,而不仅仅是将代码扔出去。