我将Ajax与php 一起使用
$("#test1").click(
....
function(data){
document.getElementById("test2").innerHTML=data;
}
)
php返回数据
echo "<input type='text' id='test'>";
如何从innerHTML中获取Id属性?非常感谢。
您不需要从innerHTML获取id,只需:
document.getElementById("test2").id;//Gets the id for element test2
您可以使用javascript获取内部HTML值
通过使用:var a=document.getElementById('test').value
a将具有所需的响应。
通常,如果您使用attr方法,它应该像一样工作
var a = $('#test').attr('id');