2

I'm trying to write a simple jQuery function to click on the "following" buttons of Medium. I wrote this but it returns "Uncaught ReferenceError: jQuery is not defined"

__cnt__ = 0;
jQuery('.button-activeState').each(function(i, ele) {
    ele = jQuery(ele);
    if (ele.css('display') != 'inline') {
        //alert('already following:', i);
        return;
    }
    setTimeout(function() {
        ele.click();
    }, __cnt__++ * 500);
});

What am I doing wrong?

1
  • 7
    Is jQuery included ? Is this script executing before jquery is included ? Commented Nov 2, 2015 at 18:49

2 Answers 2

4

To include jQuery 2.1.4, you could run the following in the console:

var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
Sign up to request clarification or add additional context in comments.

Comments

0

"Uncaught ReferenceError: jQuery is not defined"

Mean that there's no jquery included, so make sure that jquery is included, and place your script after include of librairy.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.