Reputation: 1173
I have some jQuery that looks like:
$(function() {
var productTextTemplate = $('#product-text-template').html();
var productTemplate = $('product-template').html();
var product = productTextTemplate.appendTo(productTemplate);
alert(product);
});
What I'm trying to do is combine:
<div id="product-template">
Hello
</div>
and
<div id="product-text-template">
World
</div>
so it becomes:
<div id="product-template">
Hello
<div id="product-text-template">
World
</div>
</div>
but I'm getting the error: Uncaught TypeError: undefined is not a function
. I also made a JSFiddle, here: http://jsfiddle.net/q76EQ/.
Thanks for all help!
Upvotes: 0
Views: 1339
Reputation: 364
ِAlso, you may forget to write #
to product-template
to be
var productTemplate = $('#product-template').html();
Upvotes: 1
Reputation: 1078
Remove the .html()
from var productTextTemplate = $('#product-text-template').html();
$(function() {
var productTextTemplate = $('#product-text-template');
var productTemplate = $('product-template').html();
var product = productTextTemplate.appendTo(productTemplate);
alert(product);
});
Upvotes: 4