我可能在这里忽略了一件小事,但有人可以告诉我为什么当按下按钮时div
中的文字没有改变?
<body>
<div id="testing">Hello Again :-)</div>
<br/><br/>
<button onclick="changingText()">Change Me!</button>
</body>
<script type="text/javascript">
function changingText()
{
//This is the setter of the innerHTML property in jQuery
$('#testing').html('Hello World');
//This is the getter of the innerHTML property in jQuery
//var helloWorld = $('#output').html();
}
</script>
答案 0 :(得分:0)
<body>
<div id="testing">Hello Again :-)</div>
<br/><br/>
<button onclick="changingText()">Change Me!</button>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#btnChangeText').click(function (event) {
$('#testing').html('Hello World');
event.preventDefault();
});
});
</script>
</body>
如果出现任何问题,请告诉我。 感谢