如何替換 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章