I have two similar selections. The first uses a <div>
tag, which works fine, the second uses a newly <template>
tag, which doesn't work anymore.
Can anyone tell me how to get this to work with jQuery using the <template>
tag?
HTML
<div id="div">
<div>content</div>
</div>
<template id="template">
<div>content</div>
</template>
JavaScript
var $div = $('#div');
var $content = $div.find('div');
console.log($content); //works ($content.length == 1)
var $template = $('#template');
var $content = $template.find('div');
console.log($content); //doesn't work ($content.length == 0)
$template[0].outerHTML
works, so it should theoretically be possible for jQuery to work with the<template>
tagcontent
attribute exists? If so, use it - if not, the regularjQuery
way should work?