Javascript 如何使用jquery更改模式内的文本?

Javascript 如何使用jquery更改模式内的文本?,javascript,jquery,html,twitter-bootstrap,modal-dialog,Javascript,Jquery,Html,Twitter Bootstrap,Modal Dialog,大家好,我试着用pokeapi创建一个pokedex。 我的模型如下所示: <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered" role="document"&g

大家好,我试着用pokeapi创建一个pokedex。 我的模型如下所示:

<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
  <div class="modal-content">
    <div class="modal-header">
      <h5 class="modal-title" id="exampleModalLongTitle"> #1 Pokemon-Name</h5>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    <div class="modal-body">
      Some information
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
    </div>
  </div>
</div>
const button = document.createElement("BUTTON");
button.setAttribute("data-toggle","modal");
button.setAttribute("data-target","#exampleModalCenter");
我的问题是,我怎样才能把《情态》的标题和描述改成《bulbasaur》

完整代码:

模式标题:

document.getElementById("exampleModalLongTitle").innerHTML="bulbasaur"; //pure JS
$("#exampleModalLongTitle").html("bulbasaur") //with Jquery
对于说明,请向HTML元素添加id属性

<div id="modalDescription" class="modal-body">
      Some information
</div>

document.getElementById("modalDescription").innerHTML="bulbasaur description"; // pure JS
$("#modalDescription").html("bulbasaur description") //with Jquery

一些信息
document.getElementById(“modalDescription”).innerHTML=“bulbasaur description”;//纯JS
$(“#modalDescription”).html(“bulbasaur description”)//带Jquery
使用纯javascript:

document.getElementById('exampleModalLongTitle').textContent = 'Bulbasaur';
使用jQuery:

$('#exampleModalLongTitle').html("Bulbasaur");

对包含描述的元素执行相同操作。

您可以使用的id获取div的引用,并在其中设置内容

//In Jquery
$('#exampleModalLongTitle').html("your text");

//In js
document.getElementById('exampleModalLongTitle').textContent = 'you text';

为包含要更改唯一ID属性的文本/数据的每个元素指定一个唯一ID属性,并执行
$('#unique_ID').html('text/data here')