html代码:<button onclick="ServerDetail()">codm-lobby-0001</button>js函数:function ServerDetail() { var btn = $(this); var button_val = btn.html(); alert(button_val); var root_dir = "/monitor/servers/detail/"; var server_url = root_dir.concat(button_val); $.get(server_url, function(data, status){ alert(data); } );}这是我在网上百度的办法,但是button_val为什么弹出一个undefined。请各位网友帮帮忙,谢谢了。
6 回答
海绵宝宝撒
TA贡献1809条经验 获得超8个赞
<button onclick="ServerDetail(this)">codm-lobby-0001</button>
function ServerDetail(_this) {
var btn = $(_this);
var button_val = btn.html();
}
侃侃无极
TA贡献2051条经验 获得超10个赞
<button onclick="ServerDetail($event)">codm-lobby-0001</button>
function ServerDetail(e) {
$(e.target).html();
//...
}
添加回答
举报
0/150
提交
取消
