Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:03:06+00:00 2026-06-13T09:03:06+00:00

I have 2 divs with 2 different class: div class name is: good div

  • 0

I have 2 divs with 2 different class:

  1. div class name is: good

  2. div class name is: bad

I would like to click with javascript (user script) randomly for this divs. I never coded in javascript i just found this code in internet.

I have this code:

function addJQuery(callback) {
  var script = document.createElement("script");
  script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
  script.addEventListener('load', function() {
    var script = document.createElement("script");
    script.textContent = "(" + callback.toString() + ")();";
    document.body.appendChild(script);
  }, false);
  document.body.appendChild(script);
}

function main() {
setInterval(function(){
$('div.good').click();
$('div.bad').click();
}, 5000);

}
addJQuery(main);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:03:07+00:00Added an answer on June 13, 2026 at 9:03 am

    It seems like what you are looking to do is perform an action with one of these two divs. It doesn’t really make sense to fake a click, because all that does is run code, which could just as easily be executed in another, far more convenient manner. What do you want to happen when the div is clicked?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of divs: <div class=some_class active>Some Content</div> <div class=some_class>Different Content</div> <div
So I have the html code: <fieldset> <legend>Log On</legend> <div class=altregrow> <label for=UserName>User name</label>
I have four divs each with the same ID but different class. <div id=inner
I have displayed a row of items with same div class name but different
I have multiple divs in a wrap, they have different height. I'd like to
I have a bunch of elements like the following: <div class=droppableP id=s-NSW style=width:78px; height:63px;
For example if I have html like this: <div id=id> <div class=class1> <div class=class2
I have the following divs: <div id=container> <div class=different_class></div> <div class=child></div> <div class=child></div> <div
i have 5 div's of the same class but different id stacking on top
I have some div elements having class name hover , these div elements have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.