如何替换 div 元素内的文本? - How do I replace text inside a div element?

问题:

I need to set the text within a DIV element dynamically.我需要在 DIV 元素中动态设置文本。 What is the best, browser safe approach?最好的浏览器安全方法是什么? I have prototypejs and scriptaculous available.我有prototypejs和scriptaculous可用。

<div id="panel">
  <div id="field_name">TEXT GOES HERE</div>
</div>

Here's what the function will look like:下面是函数的样子:

function showPanel(fieldName) {
  var fieldNameElement = document.getElementById('field_name');
  //Make replacement here
}

解决方案:

参考一: https://en.stackoom.com/question/Vgn
参考二: https://stackoom.com/question/Vgn
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章