Skip to content
Advertisement

Getting an undefined error when trying to pull the URL from my css using JS

I thought I got this one right, apparently not as I’m getting an “undefined” error

Here is my CSS

JavaScript

Will this bit of javascript define https://www.example.com/countries ?

JavaScript

enter image description here

Any suggestions or guidance would be very much appreciated

Advertisement

Answer

It looks like you might not have the $ defined.

For this simple case, you should be able to use document.querySelectorAll in its place:

JavaScript
JavaScript

Note that this doesn’t have full support below IE9, if you need that then i’d recommend jQuery.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement