Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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
Javascript 单击复选框获取Fexigrid中的表行id值?_Javascript_Jquery_Html_Css_Flexigrid - Fatal编程技术网

Javascript 单击复选框获取Fexigrid中的表行id值?

Javascript 单击复选框获取Fexigrid中的表行id值?,javascript,jquery,html,css,flexigrid,Javascript,Jquery,Html,Css,Flexigrid,我在FlexGrid上工作,在脚本编写方面没有什么问题。我已成功创建了FlexiGrid并添加了复选框。单击复选框,我想选择所需的行。单击任何行时,它会在中设置class='trSelected'。我尝试了一些脚本来设置复选框单击,但不起作用。请告诉我如何解决这个问题 <script type="text/javascript"> function checkedCall() { if( $('#checkNote').is(':checked')){ //$("#tblf

我在FlexGrid上工作,在脚本编写方面没有什么问题。我已成功创建了FlexiGrid并添加了复选框。单击复选框,我想选择所需的行。单击任何行时,它会在
中设置class='trSelected'。我尝试了一些脚本来设置复选框单击,但不起作用。请告诉我如何解决这个问题

<script type="text/javascript"> 
function checkedCall() {
 if( $('#checkNote').is(':checked')){
   //$("#tblflex > tr:first").addClass("trSelected");
   //$(this).parents('tr:first').addClass('trSelected');
   alert('Selected' + $(this).parents('tr:first').attr('id')); //unable to find the ID
 }else{
  alert('NOTSelected');
  //$("#tblflex > tr:first").removeClass("trSelected");
  //$(this).parents('tr:first').removeClass('trSelected');
 }
}

函数checkedCall(){
如果($('#checkNote')。是(':checked')){
//$(“#tblflex>tr:first”).addClass(“trSelected”);
//$(this).parents('tr:first').addClass('trSelected');
警报('Selected'+$(this).parents('tr:first').attr('id');//找不到id
}否则{
警报(“未选定”);
//$(“#tblflex>tr:first”).removeClass(“trSelected”);
//$(this).parents('tr:first').removeClass('trSelected');
}
}
HTML代码:

<table id="tblflex" class="flexCLS" style="display: table;" border="0">
 <tbody>
  <tr id="row101">
   <td align="left">
    <div style="text-align: left; width: 40px;">
     <input type="checkbox" id="checkNote" onclick="checkedCall();">
    </div>
   </td>
 </tr>
  <tr id="row187">
   <td align="left">
    <div style="text-align: left; width: 40px;">
     <input type="checkbox" id="checkNote" onclick="checkedCall();">
   </div>
 </td>
</tr>


谢谢

问题是您的所有复选框都具有相同的ID“checkNote”

这是一个提议的解决方案

HTML


还有JS代码

<script type="text/javascript"> 
function checkedCall(this) {
 if( $(this).is(':checked')){
   //$("#tblflex > tr:first").addClass("trSelected");
   //$(this).parents('tr:first').addClass('trSelected');
   alert('Selected' + $(this).parents('tr:first').attr('id')); //unable to find the ID
 }else{
  alert('NOTSelected');
  //$("#tblflex > tr:first").removeClass("trSelected");
  //$(this).parents('tr:first').removeClass('trSelected');
 }
}

函数checkedCall(此){
如果($(this).is(':checked')){
//$(“#tblflex>tr:first”).addClass(“trSelected”);
//$(this).parents('tr:first').addClass('trSelected');
警报('Selected'+$(this).parents('tr:first').attr('id');//找不到id
}否则{
警报(“未选定”);
//$(“#tblflex>tr:first”).removeClass(“trSelected”);
//$(this).parents('tr:first').removeClass('trSelected');
}
}
<script type="text/javascript"> 
function checkedCall(this) {
 if( $(this).is(':checked')){
   //$("#tblflex > tr:first").addClass("trSelected");
   //$(this).parents('tr:first').addClass('trSelected');
   alert('Selected' + $(this).parents('tr:first').attr('id')); //unable to find the ID
 }else{
  alert('NOTSelected');
  //$("#tblflex > tr:first").removeClass("trSelected");
  //$(this).parents('tr:first').removeClass('trSelected');
 }
}