Image reload onclick event - help needed

Image reload onclick event - help needed

All:

I'm brand spankin' new to jQuery, and I need to get in right away and add something. Normally, I read, test, try (repeat) but I have a massive deadline, and was just given code from someone else.

I have the follwing onclick event currently in place:

<a onclick="$('tr.segment_list_for_0').toggle(); $(this).parent().parent().toggleClass('selected'); $(this).find('img').toggle(); ">


This toggles whether table rows below the link display or not. This works great.

Now, I need to update the link so when it is toggled, it also updates just 1 image on the page with a new image. I have tried the following:

<a onclick="$('tr.segment_list_for_0').toggle(); $(this).parent().parent().toggleClass('selected'); $(this).find('img').toggle(); $('#bytespackets').attr('src', 'graph.php?v=bytespackets&h=24&ts=1232477583&sensor=newsensor');">


The image on the page has an id="bytespackets". When clicked, I get:

$('#bytespackets').attr is not a function


What can I do to update the image with a newer one when the user toggles the hidden data? It would also be ideal if, when they untoggle, the original image re-appeared.

TIA!