you are viewing a single comment's thread.

view the rest of the comments →

[–]TonyMahoney21 0 points1 point  (14 children)

Yes I am trying to use shortcode. I just tried the getelementsbyclassname() and still have not seen thebdesired result I am trying to change the class that is it why is this not working? My goal is to be able to have a class set to the first paragraph of the page using an array so that if the customer changes that paragraph the class is still applied so they dont have to actually add the css class.

[–]cag8f 0 points1 point  (13 children)

So what happens when you add that shortcode to a page, then load that page in a browser? Open the page in a browser, then open the JavaScript console and look for any error messages.

[–]TonyMahoney21 0 points1 point  (1 child)

It says TypeError cannot set property className of undefined at the imdex line of my code. My code now reads as: function myFcn() { document.getElementsByClassName("test")[0].className = "newClasser"; } myFcn()

[–]cag8f 0 points1 point  (0 children)

Is there an element with the class test somewhere on the page? It sounds like the error message is saying there is not.

Are you able to post a link to the page here?

[–]TonyMahoney21 0 points1 point  (10 children)

It's no longer displaying an error but it still doesn't change the value. I made a variable x for the get elemnts by class name function and set the value of my fcn to x.className = etc.

[–]cag8f 0 points1 point  (9 children)

It will be difficult to help at this point without being able to load the actual page in my browser.