0

Is it possible to change the HTML rendered by Django by changing the variables (context) with Javascript?

For example, say I render, {{ item }}, can I hide everything rendered by {{ item }} by hiding the Django variable itself? Or do I have to select the rendered HTML at that point. How do Django's context preprocessors work with Javascript?

4

1 回答 1

0

您必须记住,JavaScript 在呈现 HTML之后运行。所以不,不可能做你想做的事(用 JS 改变 Django 变量)。

如果要隐藏 {{ item }} 的内容,请将其包装在 HTML 元素中,然后使用 JS 选择并隐藏它。

希望能帮助到你。

于 2013-07-31T22:40:09.053 回答