admin管理员组文章数量:1323150
I have this div:
<div id="libraryDisplay">asdf</div>
and this code:
$('#libraryDisplay').val(booksList);
and booksList is a string. It's still displaying "asdf". Any suggestions?
I have this div:
<div id="libraryDisplay">asdf</div>
and this code:
$('#libraryDisplay').val(booksList);
and booksList is a string. It's still displaying "asdf". Any suggestions?
Share asked Jan 22, 2014 at 22:04 ionox0ionox0 1,1112 gold badges14 silver badges21 bronze badges 1- div elements don't have a value. – Kevin B Commented Jan 22, 2014 at 22:15
2 Answers
Reset to default 6val
is for form elements. If you're trying to set the text of the <div>
, use text
instead:
$('#libraryDisplay').text(booksList);
If booksList
is actually an HTML fragment (and you're reasonably sure it's ing from a safe source and doesn't have the potential to corrupt your page) use html
:
$('#libraryDisplay').html(booksList);
Try
$('#libraryDisplay').html(booksList);
本文标签: javascriptChange value of div using jquery val() not workingStack Overflow
版权声明:本文标题:javascript - Change value of div using jquery .val() not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742144110a2422711.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论