开发者

display html content in div

How to display html content

 <script type="text/javascript">
    function replaceContent(show) {

         var displ开发者_开发知识库ay = new Array();
         display[1] = 1.html;
         display[2] = 2.html; 

         document.getElementById("ShowItems").innerHTML = display[show];

    }
    </script>

    <a href="#" onclick="replaceContent(1)">1</a>
    <a href="#" onclick="replaceContent(2)">2</a>
    <a href="#" onclick="replaceContent(3)">3</a>
    <div id="ShowItems">...</div>

thankyou.


wha?

try display[1] = "<b>Content 1</b>"; ie it is HTML already.

maybe i don't understand your question...

also arrays are zero indexed so you should start at 0-2 instead of 1-3.


You want to populate #ShowItems with the contents of 1.html, 2.html, etc? This doesn't make very much sense, unless 1.html and 2.html are really just page fragments. Consider iframes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜