简体   繁体   中英

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.

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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