On Tuesday, December 3, 2019 at 10:04:09 AM UTC-5, Jared wrote:
>
>
> I made a little JavaScript function (wind.js) that will update the Seasons
> *current_widget* table with wind values from CRT realtime.txt. The
> function works perfectly fine if I drop it into the browser console after
> the page loads, but for the life of me I cannot get this thing loaded by
> itself. The console always shows the error *$ is not defined* in
> wind.js. The errant line is *tbl = $('.widget_contents',
> $('current_widget'));* where I am grabbing the table object.
>
first of all, nice work so far!
$ is used by jquery. as far as i know it does nothing in pure javascript.
http://xahlee.info/js/js_dollar_sign_in_javascript.html
https://www.quora.com/Learning-programming-Why-would-a-JavaScript-variable-start-with-a-dollar-sign
you probably want something like this:
var tbl = document.getElementById('current_widget')
then traverse the DOM from there to get the object you want.
you might want to put an id on each DOM element that you want to modify -
then there is no need to traverse the DOM. if you use the observation name
for each id then that makes it even easier.
m
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/12db5da0-1876-460d-8105-1d6fe03a5e4e%40googlegroups.com.