Adding javascript to style an element

Home Forums Plugin Integration Adding javascript to style an element

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  pitamaria 6 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #3576


    I’m trying to style a particular element that, due to the construction of the plugin that houses it, can only be controlled via its name attribute. According to some web research, the following snippet will get the job done.

    var v_obj = document.getElementsByName('Vaccinations');

    This snippet needs to appear in my child theme’s head, right? And the best way to do that is via my functions.php, right?

    I only need it to run in one or two specific places, identifiable by a page class (e.g. body class=”page-id-80″) or element id (e.g. form id=”form-10-1376150103″).

    Any help I could get to make this snippet run successfully would be greatly appreciated. Thanks in advance.


    Scott Nix

    Gist –

    The conditional of is_page ( 80 ) makes it so it will only run on that specific page. If you needed it to run on more pages, just comma seperate them is_page ( 80, 81 )



    @scott: You’ve helped me before and I so appreciate it.

    Your snippet didn’t work, unfortunately, but I attribute that to the script, not your syntax. Regardless, I found a different solution so I’m setting this topic as “resolved”.

    For those curious, the solution I’m settling for is detailed here: It’s admittedly buggy in many browsers but I’m gonna roll the dice.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Adding javascript to style an element’ is closed to new replies.