这是我的代码(仅此而已)
$(document).ready(function() {
$(".system").click(function() {
var sid = this.id;
alert(sid); // Outputs correct id
$("#graph").html('<img src="graph.php?system=' + sid + '" />'); // sid seems to be null (call looks like "http://host/grap.php?system=")
})
})
显然,警报sid
有效,而sid
在选择器的 html 方法中使用则无效。我也尝试将值写入表单输入,然后从那里读取,但这也不起作用。
我认为,html 方法不支持其他调用或变量访问。对此有什么解决方法?