简体   繁体   English

传递参数后,如何在模板中的元素中创建ID?

[英]How to create id in element in template when I have passed parameter?

How to create id in element in template when I have passed parameter ? 传递参数后,如何在模板中的元素中创建ID? I have tried something like 我已经尝试过类似的东西

<button id="p_"+{{key}} >TEST</button>

but in rendered HTML id is just p_ . 但在呈现的HTML中,id仅为p_ Can someone tell me how to achieve this ? 有人可以告诉我如何实现吗?

<button id="p_{{key}}">TEST</button>

you need the key to be Inside the quotes 您需要将密钥放在引号内

I'm assuming you were using + to concat strings. 我假设您使用+连接字符串。 I don't believe html supports any operations like that. 我不相信html支持任何这样的操作。

<button id="p_{{key}}">TEST</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想根据作为参数传递给我的模板的数组元素显示星星 - I want to show stars based on an array element that is passed as a parameter to my template 当我没有它的 id 时,如何使用 Selenium 与元素交互? - How to interact with an element with Selenium when I don't have it's id? 当作为参数传递时,能否使Django的{%url%}模板标记忽略无,因此使该参数可选? - Can I make Django's {% url %} template tag ignore None when passed as a parameter, so making the parameter optional? 为什么变量在 Python 中按值传递时具有相同的 id - Why do variables have same id when they are passed by value in Python 如何获得在URL中传递的参数? - How can I get a parameter passed in the url? 当“无”或无参数传递时,如何在函数中接受默认参数? - How can I accept default parameter in function when 'None' or no argument is passed? 具有ID属性时如何引用NDB实体 - How to reference an ndb entity when I have the ID attribute 如何在 Python 中创建一个动态文本参数传递给 function 的 dataframe - How to create a dataframe with a dynamic text parameter passed to a function in Python 当传递给模块中的函数时,如何设置变量作用域的默认值? - How can I have / effect a default value for variable scoping when passed to a function in a module? 参数如何传递到构造函数中? - How is the parameter passed into the constructor?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM