JSFiddle - React, Tailwind, and code Playground
by Rapha Souza
HTML
<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<!DOCTYPE html>
<html>
<head>
<title>
JavaScript |
Add a key/value pair to JSON object
</title>
</head>
<body style="text-align:center;">
<h1 style="color:green;">
GeeksForGeeks
</h1>
<p id="GFG_up"
style=" font-weight: bold">
</p>
<button onclick="Geeks()">
Click to add
</button>
<p id="GFG_down"
style="color:green;
font-weight: bold" ;>
</p>
<script>
var GFG_p = {
prop_1: "val_1",
prop_2: "val_2",
prop_3: "val_3"
};
var p_up =
document.getElementById("GFG_up");
var p_down =
document.getElementById("GFG_down");
p_up.innerHTML =
JSON.stringify(GFG_p);
function Geeks() {
GFG_p.prop_4 = "val_4";
p_down.innerHTML = JSON.stringify(GFG_p);
}
</script>
</body>
</html>
CSS
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}