Hi Corry,
You are on the right track here. I would expect you to encounter issues with the script in its current form, because it runs on the document's ready event. The form has likely not finished initializing at this time.
I suggest you wrap this in MktoForms2.whenReady, since you want the form to be fully initialized before maipulating its fields. You mentioned that you tried this method unsuccessfully; can you describe the issue you encountered using whenReady?
I have posted below a script that should do what you're asking. It wraps your code in whenReady, and only searches the children of the Marketo form element for the specific fields.
Best,
Kyle
jQuery(window).ready(function() {
MktoForms2.whenReady(function(form) {
var formElement = form.getFormElem();
jQuery(formElement).find('input[type=hidden]').each(function() {
jQuery(this).parents('.mktoFormRow').addClass('hidden');
});
jQuery(formElement).find('input[type=checkbox]').each(function() {
jQuery(this).parents('.mktoFormRow').addClass('checkbox');
});
});
});