I've tried searching everywhere for an answer to this so forgive me if it's out there somewhere, I was unable to find it.
I'm writing a simple Chrome Extension which places buttons on a page which change the values of input items on that page.
Simplified version of my content.js file:
urlField = $('#someidonthepage');
function changeValue(){
urlField.val('test');
}
When I execute this code in the console, it works fine and I am able to call that function. With my extension however, it only works when I declare urlField inside of the function.
This obviously wouldn't be a big deal if it weren't for the fact that I have a bunch of functions and variables and I feel like it would be really inefficient to declare all 10 of them inside of every function.
I have tried using "window." and other things I found online regarding Global variables but I'm starting to think this has more to do with Chrome Extensions than incorrect syntax because it works fine in console.
I'm pretty much just getting started with programming so please let me know if there's any other info I can provide!
Thanks in advance!