我尝试在jQuery中访问表数据,使用jenis_perkara_kode
选择器更改它的类,但它不起作用。也许我想念一些东西。请参阅以下示例代码:
)AS sisa_bulan_lalu FROM bulan WHERE bulan=$cek ";

$sql3="SELECT ( SELECT
COUNT(p.perkara_id)
FROM
perkara AS p
LEFT OUTER JOIN perkara_putusan AS putus
ON p.perkara_id = putus.perkara_id
WHERE
LEFT(p.tanggal_pendaftaran, 7) <= '$gab'
AND LEFT(putus.tanggal_minutasi, 7) = '$gab' AND p.jenis_perkara_kode
&#13;
'delete the item ${row.name}'
&#13;
答案 0 :(得分:1)
使用变量exoplayer
是不合适的,根据您当前的代码将其用作字符串 constructor(props) {
super(props);
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
};
const user = firebase.auth().currentUser;
if (user != null) {
this.itemsRef = this.getRef().child(`Stores/${user.uid}/`);
} else {
Alert.alert('Error', 'error!');
}
this.connectedRef = firebase.database().ref('.info/connected');
}
componentWillMount() {
this.connectedRef.on('value', this.handleValue);
}
componentWillReceiveProps() {
this.connectedRef.on('value', this.handleValue);
}
componentWillUnmount() {
this.connectedRef.off('value', this.handleValue);
}
/*eslint-disable */
getRef() {
return firebase.database().ref();
}
/*eslint-enable */
handleValue = (snap) => {
if (snap.val() === true) {
this.listenForItems(this.itemsRef);
} else {
//this.offlineForItems();
}
};
listenForItems(itemsRef) {
this.itemsRef.on('value', (snap) => {
const items = [];
snap.forEach((child) => {
items.unshift({
title: child.val().title,
_key: child.key,
});
});
offline2.save('itemsS', items);
this.setState({
dataSource: this.state.dataSource.cloneWithRows(items),
});
});
}
offlineForItems() {
offline2.get('itemsS').then((items) => {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(items),
});
});
}
deleteConfirm(data, secId, rowId, rowMap) {
Alert.alert(
'Warning!',
'Are you sure?',
[
{ text: 'OK', onPress: () => this.deleteRow(data, secId, rowId, rowMap) },
{ text: 'Cancel', onPress: () => this.deleteCancel(data, secId, rowId, rowMap) },
]
);
}
deleteCancel(data, secId, rowId, rowMap) {
rowMap[`${secId}${rowId}`].closeRow();
}
deleteRow(data, secId, rowId, rowMap) {
rowMap[`${secId}${rowId}`].closeRow();
this.itemsRef.child(data._key).remove();
offline2.get('itemsS').then((items) => {
const itemsTemp = items;
let index = -1;
for (let i = 0; i < itemsTemp.length; i += 1) {
if (itemsTemp[i]._key === data._key) {
index = i;
}
}
if (index > -1) {
itemsTemp.splice(index, 1);
}
// Decrement stores counter
offline2.get('storesTotal').then((value) => {
const itemsReduce = value - 1;
this.setState({ storesValue: itemsReduce });
offline2.save('storesTotal', itemsReduce);
});
offline2.save('itemsS', itemsTemp);
this.setState({
dataSource: this.state.dataSource.cloneWithRows(itemsTemp),
});
});
}
,您需要更改
bar
到
bar
答案 1 :(得分:1)
$(function(){
$( "#hit" ).click(function() {
bar = +($('#num').text()) + 1;
$("tr td:nth-child("+bar+")").toggleClass('on off');
});
});
.on {
background-color: green;
}
.off {
background-color: grey;
}
table {
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="num">1</div>
<br>
<table>
<tr>
<td class="on"> </td>
<td class="off"> </td>
<td class="off"> </td>
<td class="off"> </td>
<td class="off"> </td>
</tr>
</table>
<br>
<button id="hit">Hit me!</button>
我认为您想要切换on
和off
,您需要让两个课程都进行切换。
也正确连接
答案 2 :(得分:1)
你的功能有点偏。首先,你不是将bar作为变量引用,而是只包括字符串&#34; bar&#34;在选择器字符串中。其次,toggleClass()很好,但你需要切换.on和.off,否则你的浏览器会尝试应用这两种样式(因为&#34; .off&#34;仍然是一类第n个孩子)。请参阅下面的代码:
$(function(){
$( "#hit" ).click(function() {
bar = +($('#num').text()) + 1;
$("tr td:nth-child(" + bar + ")").toggleClass('on off');
});
});
&#13;
.on {
background-color: green;
}
.off {
background-color: grey;
}
table {
border: 1px solid black;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="num">1</div>
<br>
<table>
<tr>
<td class="on"> </td>
<td class="off"> </td>
<td class="off"> </td>
<td class="off"> </td>
<td class="off"> </td>
</tr>
</table>
<br>
<button id="hit">Hit me!</button>
&#13;
另外,以下是您可能想要做的其他事情: - 点击事件触发后更新$(&#39;#num&#39;)的值 - 检查以确保存在第n个孩子