Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

saldtch on "Unable to add attribute to an element using setAttribute() or attr()"

$
0
0

I added the following

(function addclick(){
getElementsByClassName("testclass").setAttribute("onclick", "myFN()");
})()

to the custom.js of my theme but I just can't update the target element.
I tested the function by replacing with an alert and it worked so it shouldn't be anything to do with it not be invoked. I also tried the jQuery attr() but also with no luck.

Any ideas? or I am just missing something?
Thanks!


Viewing all articles
Browse latest Browse all 8245

Trending Articles