change the generated id of the ninja forms button for another id

  javascript, jquery, ninja-forms, wordpress

Ninja form generates an automatic id in one of its elements, in this case it is an input with the value "nf-field-4_1".

ID generated by the plugin ninja forms

What I need to do is to change the default id "nf-field-4_1" to a custom id e.g "my-id".

I tried using Jquery, like this:

jQuery(document).ready(function($) {
    $('.ninja-forms-field').prop('id', 'my-id');

I also tried with pure js, with the console calls that can be effective:

document.getElementById("nf-field-4_1").setAttribute("id", "modified");

When I test it from the developer tools console, it does make the change effective. But when I upload it for example to my footer to some custom block of js code, it does not update and remains the id "nf-field-4_1".

How can I change this id in a more effective way? As I need to tag that id differently in google analytics console.

Source: Ask Javascript Questions