我是 JavaScript 新手 我已经创建了这段代码,它几乎可以工作。 href 有效,但如何将固定电话号码放在 a href 标记之间?
document.write
不起作用。
有什么想法吗?
<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
</head>
<body>
<script type="text/javascript">
function fix(nummer) {
var nieuw = nummer.replace(/\D/g,'');
var output = document.getElementById("nummer");
var href = 'http://10.0.1.151/?call=' + nieuw;
output.setAttribute("href", href);
output.document.write(nieuw);
}
</script>
<label>Typ telefoonummer</label><input id="telefoon" style="margin-left: 30px" type="text" onblur="fix(this.value)" />
<span><a target="_blank" id="nummer">Call [how do I get the fixed number here??]</a></span>
</body>
</html>
最佳答案
设置元素的innerText
属性。
output.innerText = "Call "+nummer;
关于javascript - 如何在 a href 标签之间放置一些文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23301593/