在 javascript 中同时出现双击事件和输入事件
Double click event and Enter event in a same time in javascript
我想在按下回车键或双击时调用事件。
我写这段代码是为了按下 Enter 键,但我不知道如何为双击插入条件。
onClickNode: function (node) {
$(document).keyup(function (e) {
if (e.which == 13) {
$.ajax({
url: '@Url.Action("EditNode", "Admin")',
type: 'POST',
data: { id: node.data.id,name:node.data.name},
success: function (data) {
if (data.Success) {
// do something
}
//do something
});
},
});
}
});
}
你能用 enter 或双击来更改此代码吗?
$(document).on("keyup", function (e) {
if (e.which == 13) {
commonMethod(node);
}
});
$(document).on("dblclick", function (e) {
commonMethod(node);
});
function commomMethod(node) {
$.ajax({
url: '@Url.Action("EditNode", "Admin")',
type: 'POST',
data: {
id: node.data.id,
name: node.data.name
},
success: function (data) {
if (data.Success) {
// do something
}
//do something
}
});
}
我想在按下回车键或双击时调用事件。
我写这段代码是为了按下 Enter 键,但我不知道如何为双击插入条件。
onClickNode: function (node) {
$(document).keyup(function (e) {
if (e.which == 13) {
$.ajax({
url: '@Url.Action("EditNode", "Admin")',
type: 'POST',
data: { id: node.data.id,name:node.data.name},
success: function (data) {
if (data.Success) {
// do something
}
//do something
});
},
});
}
});
}
你能用 enter 或双击来更改此代码吗?
$(document).on("keyup", function (e) {
if (e.which == 13) {
commonMethod(node);
}
});
$(document).on("dblclick", function (e) {
commonMethod(node);
});
function commomMethod(node) {
$.ajax({
url: '@Url.Action("EditNode", "Admin")',
type: 'POST',
data: {
id: node.data.id,
name: node.data.name
},
success: function (data) {
if (data.Success) {
// do something
}
//do something
}
});
}