未捕获的SyntaxError:无法在“文档"上执行"querySelector" [英] Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document'
问题描述
'<button id="'+item['id']+'" class="btnDeactivateKeyInChildPremiumCustomer waves-effect waves-light>ok</button>'
我使用上面的代码在jquery每个函数内部生成按钮.按钮是动态创建的,当我单击按钮时,它应该显示按钮的进度. 我正在使用 Ladda Button Loader .
I used above code for generating button inside of jquery each function.The button created dynamically and when i clicked the button , it should show the progress on the button. Im using this Ladda Button Loader.
btnDeactivateKeyInChildPremiumCustomerClick : function(event){
var id = event.currentTarget.id;
var btnProgress = Ladda.create(document.querySelector('#'+id));
//btnProgress.start(); or //btnProgress.stop();
}
然后我通过按钮,事件处理程序捕获了上面函数的事件处理.在该函数内,它将创建一个 btnProgress 对象. 之后,我可以调用start()或stop()函数.在仅一个按钮的情况下,我已经成功地工作了,而没有在每个按钮内部动态创建按钮.但是在每种情况下,执行 var btnProgress = Ladda.create(document.querySelector('#'+ id));
And then i passed the button the event handler catch the event process the above function.Inside that function it will create a btnProgress object. After that i can call start() or stop() functions.I have successfully worked the in the case of only one button without creating the button dynamically inside each . But in the for each case it is showing some errors while executing var btnProgress = Ladda.create(document.querySelector('#'+id));
错误
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#22' is not a valid selector.