[英]how to change div content with javascript?
How do i change a div with another div using javascript?? 如何使用javascript更改另一个div的div?
I want to change the content of the div but it is all plain text and no style and i want it to be styled. 我想更改div的内容,但它们都是纯文本,没有样式,我希望它具有样式。 is there a way to change the content or do i need to change the whole div and how?
有没有办法来改变内容或者我需要改变整个DIV又如何呢? i have no clue!!
我没有任何线索!!
this is the site: http://www.websteam.nl/index2.html 这是网站: http : //www.websteam.nl/index2.html
thanks in advance! 提前致谢!
what i have is this: 我所拥有的是:
function wijzigTekst(inhoud) {document.getElementById('transbox').innerHTML = inhoud; }
And this is the html: 这是html:
<ul id="nav">
<li id="nav-1"><a href="#" onmousedown="wijzigTekst('hoi')">Home</a></li>
<li id="nav-2"><a href="#" onmousedown="wijzigTekst('transsbox')">School</a></li>
<li id="nav-3"><a href="#" onmousedown="wijzigTekst('is')">Over Websteam</a></li>
<li id="nav-4"><a href="#" onmousedown="wijzigTekst('de')">Contact</a></li>
<li id="nav-5"><a href="#" onmousedown="wijzigTekst('tekst')">Project</a></li></ul>
Create CSS style, add the content to the div and it will take the style automatically 创建CSS样式,将内容添加到div,它将自动采用样式
CSS 的CSS
h1{
border:solid 2px #009;
padding:5px 0px;
font-family:Tahoma, Geneva, sans-serif;
background-color:#000;
color:#FFF;
}
JavaScript 的JavaScript
function changediv(){
var div = document.getElementById("divData");
div.innerHTML = "<h1>Hello World</h1>";
}
HTML 的HTML
<a href="javascript:changediv();">Change Data</a>
<div id="divData"></div>
or by using jquery : 或使用jquery:
CSS 的CSS
#text {
/* style */
}
HTML 的HTML
<div id="transbox">
<div id="text"></div>
</div>
JS JS
$('#transbox #text').html('your text');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.