0
我知道答案可能会是很简单的东西,但我失去了我的脑海里没有得到这个工作:不能正确的ID传递给.replaceWith()
<button id="buttonid<?php echo $i?>" onclick="addShift(this.id)">+</button>
<script>
function addShift(id){
alert(id);
$('#id').replaceWith("<h2>TEST</h2>");
}
</script>
警报显示正确ID。但是我无法使用.replaceWith函数来工作。
$("button").replaceWith("<h2>TEST</h2>");
这是工作的方式。我在这里大概缺少关于提交HTML ID到JavaScript的?谢谢!
非常感谢。我知道这件事很简单,但我无法实现。你拯救了一天! – Cataras