简体   繁体   English

如何将变量值与 in.html() 中的文本一起显示

[英]how to display a variable value along with the text in .html()

Hi I have a requirement of printing the value is the popup, I have used the below code嗨,我需要打印值是弹出窗口,我使用了以下代码

"code" “代码”

$('#warning').html('<p style="font-size: 12px;padding-top: 13px;">The updated list value is <p>' + var11);

在此处输入图像描述

but i wanted the value 500 to be displayed next to the text in the same line但我希望值 500 显示在同一行中的文本旁边

can some one help me out with this有人可以帮我解决这个问题吗

Thanks谢谢

Just need to concenenate with + inside the <p> tag.只需要在<p>标签内用+连接。

 var var11 = 500 $('#warning').html('<p style="font-size: 12px;padding-top: 13px;">The updated list value is ' + var11+'<p>' );
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="warning"></div>

Hope this helps希望这可以帮助

Just add the variable to the text of <p> tag also you can use Template strings :只需将变量添加到<p>标签的文本中,您也可以使用模板字符串

$('#warning').html(`<p style="font-size: 12px;padding-top: 13px;">The updated list value is ${var11} <p>` );

Get your variable inside the p tag:在 p 标签中获取您的变量:

$('#warning').html('<p style="font-size: 12px;padding-top: 13px;">The updated list value is' + var11 + ' <p>');

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

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