简体   繁体   English

如何在html a href标签中添加多个javascript变量

[英]how to add multiple javascript variable in html a href tag

I write this javascript but it's showing error.我写了这个javascript,但它显示错误。 can anyone solve this how to write it correctly?任何人都可以解决这个如何正确编写它?

actually I want to show button and on the button, I want link实际上我想显示按钮,在按钮上,我想要链接

pop_str = pop_str + '<a href="'+ brand1 + 'vs' + brand2 + '/'><button class="btn master_btn">Compare Now!<button></a>';

删除'/' => '/上的quote

pop_str = pop_str + '<a href="'+ brand1 + 'vs' + brand2 + '"/><button class="btn master_btn">Compare Now!<button></a>';

To simplify this you could use the back tick character ` :为了简化这一点,您可以使用反勾号字符`

pop_str =  `${pop_str}<a href="${brand1}vs${brand2}"><button class="btn master_btn">Compare Now!<button></a>`

You simply place your variables within ${variable}您只需将变量放在${variable}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM