How do I hide a lookup field title using javascript?

It is supposed to hide both fields if Choice1 answer is yes and show both fields if answer is no. The lookup field is ddOpportunity. There is also a text field ddOpportunityName. What am I doing wrong?

Code:
fd.spRendered(function() {
fd.field('Choice1').$on('change', function() {
if (fd.field('Choice1').value == 'Yes') {
$(fd.control('ddOpportunity').$el).hide();
$(fd.field('ddOpportunityName').$parent.$el).hide();
} else {
$(fd.control('ddOpportunity').$el).show();
$(fd.field('ddOpportunityName').$parent.$el).show();
}
});
});

Show:

Hide:

Hello @tnewton,

You are missing $parent in the code that hides the field, that is why only dropdown is hidden.

Please use the code below to hide the field title and dropdown:

//hide field
$(fd.control('ddOpportunity').$parent.$el).hide()
//show field
$(fd.control('ddOpportunity').$parent.$el).show()

Thank you very much! I swear I tried that before, but it worked this time. I very much appreciate your help.

Is there documentation somewhere that explains when to use ".$parent" and when not to? Button controls do not seem to like it. The button hides with "$(fd.control('btn').$el).hide();", but not "$(fd.control('btn').$parent.$el).hide();".

Hello @tnewton,

There is no separate documentation for this. But to make a long story short, if you want to hide the field or lookup control including the field title you need to use $parent.For the controls you can use only $el.

In any case, you can always address your question to our support team to find the solution.