• Resolved itexilion

    (@itexilion)


    Hello, working on next feature to show/hide description in .comment_area,
    There is
    a fieldset-fieldname1
    with .comment_area-fieldname2 (custom class hidedesc) which is hidden on document load
    and button-fieldname3 with code jQuery(‘.comment_area’).closest(‘.hidedesc’).toggle()

    The fieldset-fieldname1 is duplicated multiple times and on button press it shows .comment_area in all fieldsets, i need to modify it to show .comment_area only in related fieldset.

    Could you please guide me what is wrong?)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @itexilion

    You can assign a custom class name to every fieldset field. Ex. fieldset-a, fieldset-b, fieldset-c, and so on.

    Now, the onclick event of the button that displays the first comment_area field would be:

    jQuery('.fieldset-a .hidedesc').show();

    But if you want to hide the other hidedesc fields except the correct one, the code would be:

    jQuery('.hidedesc').hide(); jQuery('.fieldset-a .hidedesc').show();

    I’m hiding all hidedesc first, and then I’m displaying the correct one.

    And the same for the other buttons:

    jQuery('.hidedesc').hide(); jQuery('.fieldset-b .hidedesc').show();

    jQuery('.hidedesc').hide(); jQuery('.fieldset-c .hidedesc').show();

    Best regards.

    Thread Starter itexilion

    (@itexilion)

    That’s what i’m trying to avoid, to much work if there plenty of fieldsets,
    find another solution
    jQuery(this).parent().siblings('.hidedesc').toggle()

    Plugin Author codepeople

    (@codepeople)

    Hello @itexilion

    I’m sorry, but I cannot tell you if your code is correct or not without checking your form’s structure. I don’t know if the parent of the button includes a sibling with the class name hidedesc

    Please, send me the link to the form to check its structure.

    Best regards.

    Thread Starter itexilion

    (@itexilion)

    Hi, no I actually posted a code that works for me) Just if somebody will look for similar thing it will be the hint)

    Plugin Author codepeople

    (@codepeople)

    Hello @itexilion

    My apologies for the confusion, and thank you so much for sharing your solution.

    Best regards.

    Thread Starter itexilion

    (@itexilion)

    It’s ok)

    • This reply was modified 2 years, 11 months ago by itexilion.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘hide/show toggle affecting all fields’ is closed to new replies.