复选框的Jquery值始终返回

时间:2016-01-26 14:09:58

标签: jquery

我正在尝试获取复选框的值,我尝试了以下内容:

<?php
session_start();
$url1 = "https://api.github.com/user?access_token=".$_SESSION['token'];
$json2 = 'Authorization: token '.$_SESSION['token'];
$ch1 = curl_init();
curl_setopt($ch1,CURLOPT_URL,$url1);
curl_setopt($ch1,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch1,CURLOPT_HTTPGET, TRUE);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Content-Type:application/json','Accept: application/json'));
curl_setopt($ch1,CURLINFO_HEADER_OUT, true);

$result1 = curl_exec($ch1);
$result1 = json_decode($result1,true);
$headerSent = curl_getinfo($ch1, CURLINFO_HEADER_OUT ); 
curl_close($ch1);
echo $headerSent;
echo $result1;
print_r($result1);


?>

但它始终返回&#39;

这是复选框

var closedIssue = $('#closed-' + rowCounter).val();

我做错了什么?

2 个答案:

答案 0 :(得分:2)

var returnCheck = $('#closed-' + rowCounter).is(':checked');

将返回您当前的复选框状态。

答案 1 :(得分:0)

使用checked property获取.prop() method。它将返回一个布尔值。

var closedIssue = $('#closed-' + rowCounter).prop('checked');

或简单的JavaScript:

var closedIssue = document.getElementById('closed-' + rowCounter).checked;