我有一个json对象,如下所示.我想删除"otherIndustry"条目及其值,使用下面的代码不起作用.
var updatedjsonobj = delete myjsonobj['otherIndustry'];
Run Code Online (Sandbox Code Playgroud)
如何删除Json对象特定的键及其值.下面是我的示例json对象,我想删除"otherIndustry"键及其值.
var myjsonobj = {
"employeeid": "160915848",
"firstName": "tet",
"lastName": "test",
"email": "test@email.com",
"country": "Brasil",
"currentIndustry": "aaaaaaaaaaaaa",
"otherIndustry": "aaaaaaaaaaaaa",
"currentOrganization": "test",
"salary": "1234567"
};
delete myjsonobj ['otherIndustry'];
console.log(myjsonobj);
Run Code Online (Sandbox Code Playgroud)
日志仍然打印相同的对象而不从对象中删除"otherIndustry"条目.
我正在尝试通过使用以下代码来执行复制到剪贴板的操作,并且该代码在台式机浏览器中可以正常工作,但是当涉及到移动浏览器(如IOS野生动物园/ chrome)时,页面会向下滚动 $temp.val(copydatacode).select();
$('#myelementcopy').click(function(event){
var copydatacode= $('.addelement').html();
var $temp = $("<input>");
$("body").append($temp);
$temp.val(copydatacode).select(); // when the code execute at this line the mobile browser jumps to the page bottom
document.execCommand("copy");
$temp.remove();
return false;
event.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)