如何获取模板的html内容?例如,我有以下模板:获取模板的HTML内容流星
<template name="test">
<div id="example">
<strong>This is a test.</strong>
</div> <button id="btn">Get</button></template>
我需要事件单击按钮捕获div#example的HTML内容。有可能吗?
如何获取模板的html内容?例如,我有以下模板:获取模板的HTML内容流星
<template name="test">
<div id="example">
<strong>This is a test.</strong>
</div> <button id="btn">Get</button></template>
我需要事件单击按钮捕获div#example的HTML内容。有可能吗?
你可以使用JQuery(已内置到流星)本
var html = $('#example').html();
如果您分配使用Template.test.events click事件,你应该有所有的数据,在你的“这个”模板describess。
从Meteor 1.x开始,您可以使用Blaze.toHTML()。它以字符串形式返回给定模板的HTML。