win*_*f88 3 javascript jquery jquery-ui
这是阵列
var copyText= [
'this is the first line',
'Simply put, the second line',
'impressed by the third line.'
];
Run Code Online (Sandbox Code Playgroud)
这些不起作用......
$("#thisbutton").click(function () {
$("#thetext").innerHTML("meow meow");
});
Run Code Online (Sandbox Code Playgroud)
要么
$("#thisbutton").click(function () {
$("#thetext").innerHTML(copyText[1]);
});
Run Code Online (Sandbox Code Playgroud)
要么
$("#thisbutton").click(function () {
$("#thetext").text(copyText[1]);
});
$("#thisbutton").click(function () {
$("#thetext").html(copyText[1]);
});
Run Code Online (Sandbox Code Playgroud)
我错过了什么?THKS.
首先,innerHTML是一个本地DOMElement财产,而不是一种jQuery方法.
jQuery的html方法是等效的.
其次,你没有将它包装在一个ready处理程序中:
试试这个:
$(function() {
var copyText= [
'this is the first line',
'Simply put, the second line',
'impressed by the third line.'
];
$("#thisbutton").click(function () {
$("#thetext").text(copyText[1]);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8567 次 |
| 最近记录: |