0

I'm trying to follow this tutorial:

https://www.youtube.com/watch?v=2zmUSoVMyRU

And at the beginning he is typing in commands in the console such as

$('a')

which appears to be returning all the a tags in the dom. When I do this on my website, I get

TypeError: $ is not a function(…)

I also get this when running console.log as a command

function Function() { [native code] }

Im wondering is there something I have missed completely with dev tools, or is it that there might be some problem with my website overwriting the console.log function (i use wordpress)?

There is also a comment at the bottom where a user is having a similar problem (undefined errors), but it doesnt seem they resolve it.

2 Answers 2

2

Use like this.It can show you all the a tags in the dom

$$('a')
Sign up to request clarification or add additional context in comments.

3 Comments

hmm why when he does it in the vid, does he only use $ instead of $$?
Well you don't have jQuery installed, $ comes from jQuery
hmm I do have it installed though? it does appear to be working in my html code, but just not in the console?
2

A quick alternative on chrome dev tools is just to use:

$$('a')

Just to add an explanation: $('a') is using the jquery library which is a piece of JS you have to include in you site. So it will only work on dev tools if the website has jquery included. In your case it doesn't work because of that.

$$ is something built in on chrome dev tools and it will always work, no mater if jquery is included in your website or not.

About console.log you can't just type 'console.log', you have to use it like this: console.log('log my message');

So it needs to be a function call where you pass a string argument that you want to get printed out on chrome dev tools console

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.