我已经使用了别人的答案来得到这个。
查询:
$("input:checkbox:not(:checked)").each(function() {
var columnName = $(this).attr('name');
$('td:nth-child(' + columnName + '),th:nth-child(' + columnName + ')').hide();
});
$("input:checkbox").click(function() {
var columnName = $(this).attr('name');
$('td:nth-child(' + columnName + '),th:nth-child(' + columnName + ')').toggle();
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<input type="checkbox" name="1" checked="checked"/>
Run Code Online (Sandbox Code Playgroud)
当我将值放入 :nth-child(1) 时它起作用,但当我包含变量时不起作用。是我做错了还是我使用了错误的 Jquery 库。
任何帮助,将不胜感激!
是否可以使用Ajax从MySql数据库获取最后一行?
这是我的PHP:
<?php
include('../../dbconn.php');
//--------------------------------------------------------------------------
// Example php script for fetching data from mysql database
//--------------------------------------------------------------------------
$databaseName = "test";
$tableName = "generalTransactions";
//--------------------------------------------------------------------------
// 1) Connect to mysql database
//--------------------------------------------------------------------------
$con = mysql_connect($gaSql['server'],$gaSql['user'],$gaSql['password']);
$dbs = mysql_select_db($databaseName, $con);
//--------------------------------------------------------------------------
// 2) Query database for data
//--------------------------------------------------------------------------
$result = mysql_query("SELECT * FROM $tableName"); //query
$array = mysql_fetch_row($result); //fetch result
//--------------------------------------------------------------------------
// 3) echo result as json
//--------------------------------------------------------------------------
echo json_encode($array);
?>
Run Code Online (Sandbox Code Playgroud)
这是Ajax:
$(function ()
{
//-----------------------------------------------------------------------
// 2) Send a http request with …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在返回键上添加一个新块。这是我的代码,它被放置在一个开关盒中用于检查keyCode. Shift + Return 通过添加新行来工作。但只要返回,它就需要在编辑器中开始一个新的块。
// SHIFT + RETURN <br/>
if(e.shiftKey) {
const newEditorState = RichUtils.insertSoftNewline(this.state.editorState);
if (newEditorState !== this.state.editorState) {
this.onChange(newEditorState);
}
} else {
const newBlock = new ContentBlock({
key: genKey(),
type: "unstyled",
text: ""
});
const contentState = this.state.editorState.getCurrentContent();
const newBlockMap = contentState.getBlockMap().set(newBlock.getKey(), newBlock);
EditorState.push(
this.state.editorState,
ContentState
.createFromBlockArray(newBlockMap.toArray(), contentState.getBlockMap())
.set("selectionAfter", contentState.getSelectionAfter().merge({
anchorKey: newBlock.getKey(),
anchorOffset: 0,
focusKey: newBlock.getKey(),
focusOffset: 0,
isBackward: false
})),
"split-block"
);
}
Run Code Online (Sandbox Code Playgroud)
控制台中没有错误。当按下返回键时它不会执行任何操作。
我希望有人可以提供帮助。
我正在使用 javascript 创建一个对象,并希望为数据添加一个接口:
Javascript:
const childGroups: Children = {};
childGroups.children = [];
// Pushing some data
childGroups.children.push(children);
Run Code Online (Sandbox Code Playgroud)
界面:
export interface Child {
ClusterPoint
}
export interface Children {
children: {
[key: number]: Child
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Property 'children' is missing in type '{}' but required in type 'Children'. Property 'push' does not exist on type {[key: number]: Child}
数据看起来是这样的:
任何帮助,将不胜感激。
更新
感谢 Nikita Madeev,我设法让它与这个一起工作:
export interface Child {
children: {
ClusterPoint
};
}
export interface Children {
children: Child[];
}
Run Code Online (Sandbox Code Playgroud) javascript ×2
jquery ×2
ajax ×1
database ×1
draftjs ×1
html ×1
mysql ×1
php ×1
reactjs ×1
typescript ×1