Hi Altaf,
I have faced a similar problem. Try wrapping your code inside the following block:
$(window).on('elementor/frontend/init', function () {
// wait for elementor pro to load
elementorFrontend.on('components:init', function () {
// Insert your code here
});
});