<div id="node"></div>
<button onclick="onClick">点击我换名字</button>
var node = document.getElementById("node");
function onClick() {
obj.name = 'Rose'
node.innerHTML = obj.name;
}
window.onload = function(){
var obj = {}
Object.defineProperty(obj, 'name', {
value: 'Jack',
writable: false,
enumerable: true,
configurable: true
})
node.innerHTML = obj.name;
};
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.