我有以下功能:
if ($(this).find('#sel').length == 0) {
var before = $(this).text();
var title_id = $(this).parent().attr('id');
$(this).html("<select id='sel' onchange='selectdone(this, title_id=title_id)>
...</select>");
}
由此我得到Uncaught ReferenceError: title_id is not Defined
。为什么第 4 行中的 onchange
函数没有获取我之前定义的变量?我如何正确地重写上面的内容?
最佳答案
你是这个意思吗?
$(this).html("<select id='sel' onchange='selectdone(this, "+title_id+");'>...</select>");
关于javascript - 内联 javascript Uncaught ReferenceError ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11217020/