Arnie Cunningham Arnie Cunningham - 5 months ago 30
Javascript Question

How can I use javascript to click these elements?

When you sign up to pinterest, it asks you to select 5 topics to build your home feed. I'd like to execute javascript to click 1 of these buttons.

I right clicked on the area I want clicked and clicked "inspect" and I see this code come up:

<div class="interestImage" style="background-image: url(" data-element-type="211" data-aux="{ &quot;interest&quot;: &quot;hairstyles&quot; }"></div>

And here is what the page looks like:

I right clicked on the hairstyles one

Any idea if I can use javascript for this?


This will only work if this element is the first/only element on the page with this class.

Otherwise, you will need to replace the 0 inside the [] with the number that corresponds to the index of that element in the array of elements with that class. For example, it that's the 3rd element on the page with that class, replace the 0 with a 2.