charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>check it</title>
</head>
<body>
<div id="output">
<ul id="taskList"></ul>
</div>
<script type="text/javascript">
var data = `{
"tasks": {
"study": false,
"sex": false,
"gf": false,
"programming": true,
"coffee": true
}
}`;
var dataJson = JSON.parse(data);
// console.log(data);
var output = document.getElementById('output');
var tasklist = document.querySelector('#tasklist');
for(var key in dataJson.tasks){
// console.log(key, dataJson.tasks[key]);
var status = !data.JSON.tasks[key]?'': 'checked';
var html = '<li>'+ key + '<input type="checkbox" value="'+key+'"></li>';
tasklist.innerHTML += html;
// console.log(tasklist);
// console.log(html);
}
// for(var key in dataJson.tasks) {
// console.log(key);
// }
console.log(dataJson);
</script>
</body>
</html>
Please format the code you posted, by wrapping it in triple backticks. -> `
please help
What error?
can anyone execute this and give the solution..
Обсуждают сегодня