Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Jquery选择正确的id_Php_Jquery_Ajax - Fatal编程技术网

Php Jquery选择正确的id

Php Jquery选择正确的id,php,jquery,ajax,Php,Jquery,Ajax,我从数据库创建一个动态表: //[..]Typical code to fetch data from the database //$exp_id comes from the database <td><input = type = 'hidden' value = '".$exp_id."' id = 'exp_id'/><input type = 'button' id = 'alpha' value = 'a' onclick = $('.ui.small

我从数据库创建一个动态表:

//[..]Typical code to fetch data from the database
//$exp_id comes from the database
<td><input = type = 'hidden' value = '".$exp_id."' id = 'exp_id'/><input type = 'button' id = 'alpha' value = 'a' onclick = $('.ui.small.modal').modal('show'); /></td>

有什么想法吗?

ID必须是唯一的。改用类:

<td>
    <input = type = 'hidden' class='saveme' value = '".$exp_id."'/>
    <input type = 'button' class='clickme' value = 'a' onclick = $('.ui.small.modal').modal('show'); />
</td>

ID是唯一的。每个元素都需要有一个唯一的ID。循环所有元素并指定ID“exp_ID”对您不起作用-并且它不是有效的标记!使用Css类和类选择器。您的页面正在生成具有相同id的多个元素。user574632正确!我在想一些关于数组的东西,但是你的更好,更容易理解!祝你一切顺利@用户2638842没问题,很高兴我能帮上忙
<td>
    <input = type = 'hidden' class='saveme' value = '".$exp_id."'/>
    <input type = 'button' class='clickme' value = 'a' onclick = $('.ui.small.modal').modal('show'); />
</td>
$(document).ready(function(){
    $('.clickme').click(function(){
        id = $(this).parent().find('.saveme').val();
        //alert(id);
        $.post('find_expert.php',{exp1:id},function(res){
            $(".content").html(res);
        });
    });
});