console
$(document).ready(function() {
$("button").bind({
click: function() {
$("p").slideToggle()
},
mouseover: function(event) {
event.target.innerHTML = '不要点这里';
event.target.style.backgroundColor = '#fff';
event.target.style.color = '#000';
},
mouseout: function(event) {
event.target.innerHTML = '请点击这里';
event.target.style.backgroundColor = 'grey';
event.target.style.color = '#fff';
}
});
var obj = {};
Object.defineProperty(obj, 'hello', {
set: function(val) {
document.getElementById('bb').innerHTML = val;
document.getElementById('aa').value = val;
},
get: function(val) {
document.getElementById('aa').value;
document.getElementById('bb').innerHTML;
}
});
document.getElementById('aa').oninput = function(e) {
obj.hello = e.target.value;
};
obj.hello = "";
});
<p>
This is a paragraph.
</p>
<button>
请点击这里
</button>
<br>
<input type="text" id="aa" />
<span id="bb">
{{hello}}
</span>
button {
background-color: grey;
color: #fff
}