I have got one question, how to use javascript replace() in div tag? I tried it like that:
<html>
<body>
<div id="ahoj">ahoj</div>
<script type="text/javascript">
document.write(document.getElementById("ahoj").replace("ahoj","hola"));
</script>
</body>
</html>
…but it is not working.. Any ideas?
document.getElementById("ahoj")is an HTMLElement object. Usedocument.getElementById("ahoj").innerHTMLOr if you don’t want a new element:
Replace the string and set the innerHTML to the new string. Example