[英]Why is this simple javascript not doing anything?
http://jsfiddle.net/AHd34/2/ http://jsfiddle.net/AHd34/2/
$(document).ready(function(){
var a = document.createTextNode('AAA');
$jA = $(a);
$('#listContainer').append(jA);
});
<body>
<div id="content">
<div id="newLists" style="border:none;">
<!-- I'm going to need to reorganize this css so the above line does not need to happen -->
<p id="newListTitle"><span id="newListSpan">Here is a list </span></p>
<div id="listContainer">
</div>
</div>
</div>
I've never used jsfiddle before and it seems to just not be working at all. 我以前从未使用过jsfiddle,而且似乎根本无法使用。 Probably something very simple and silly.
可能是非常简单而愚蠢的东西。
2 things: 2件事:
first: in the console you can see that createTextElement doesn't exist 首先:在控制台中,您可以看到createTextElement不存在
second: you declare a variable $jA and then append a variable jA (without the $). 第二:声明变量$ jA,然后附加变量jA(不带$)。
Here's the working code: 这是工作代码:
http://jsfiddle.net/AHd34/3/ http://jsfiddle.net/AHd34/3/
$(document).ready(function(){
var a = document.createTextNode('AAA');
$jA = $(a);
$('#listContainer').append($jA);
});
Try this 尝试这个
$(document).ready(function(){
var a =document.createElement("a");
a.innerHTML="AAA";
$('#listContainer').append(a);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.