简体   繁体   English

更改html跨度内部文本

[英]change html span inner text

I want to change a value of a span I am tried to do it like that: 我想更改跨度的值,我试图这样做:

$('#tList span.k-input').textContent = "(" + list.length + ") " + $('#tList span.k-input').html();

or 要么

 $('#tList span.k-input').html() = "(" + list.length + ") " + $('#tList span.k-input').html();

if I hove over $('#tList span.k-input').html() it shows me the right value but nothing happens in the html. 如果我将$('#tList span.k-input').html()$('#tList span.k-input').html()则可以看到正确的值,但html中什么也没发生。

This should work 这应该工作

var html = "(" + list.length + ") " + $('#tList span.k-input').html();
$('#tList span.k-input').html(html)

Read more 阅读更多

.html() is used to get contents of an element. .html()用于获取元素的内容。 To set inner content you can use the same function and pass the value as a parameter. 要设置内部内容,可以使用相同的功能并将值作为参数传递。

You can visit below url for reference http://api.jquery.com/html/#html2 您可以访问以下网址以供参考http://api.jquery.com/html/#html2

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

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