<button id="'+item['id']+'" class="btnDeactivateKeyInChildPremiumCustomer waves-effect waves-light">ok</button>
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();
}
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));
Error
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#22' is not a valid selector.
This question is related to
javascript
jquery
backbone.js
Although this is valid in HTML, you can't use an ID starting with an integer in CSS selectors.
As pointed out, you can use getElementById
instead, but you can also still achieve the same with a querySelector
:
document.querySelector("[id='22']")
Source: Stackoverflow.com