Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  56] [ 3]  / answers: 1 / hits: 65420  / 11 Years ago, sun, december 8, 2013, 12:00:00

I'm trying to learn JQuery, but not doing well. Currently, I'm trying to learn how to use .append to have Ajax functionality which allows one to view new dynamic content without reloading. When I try the following, however, nothing occurs.



<!DOCTYPE html>

<html xmlns=http://www.w3.org/1999/xhtml lang=en xml:lang=en>
<head>
<title>JQuery Test</title>
<script src=http://code.jquery.com/jquery-2.0.3.min.js></script>
</head>
<body>
<div id=content/>
<script type=text/javascript>
function callback() {
$(#content).append($(qwerty));
};
$(document).ready(function() {
//window.setTimeout(callback, 100);
callback();
});
</script>
</body>
</html>


To the best of my knowledge, this should make qwerty appear as if I has simply done <div id=content>qwerty</div>, but instead I get a blank page. If I replace the .append call with alert(qwerty), it is properly displayed. What am I doing wrong?


More From » jquery

 Answers
47

You are trying to find an element with tagname qwerty in the dom like <qwerty>sometext</qwerty> and append it to #content.



To append the string qwerty to #content use



$(#content).append(qwerty);


Demo: Fiddle


[#73856] Friday, December 6, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dusty

Total Points: 739
Total Questions: 97
Total Answers: 85

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
;