Suppose I have the following HTML:
I would like to switch the src
to bar2.jpg>
The first wey is just fine, no reason to remove it first.
$("#foo").attr("src", "bar2.jpg");
$.attr serves both to get the existing attribute and to change it (depending on whether theres one or two arguments). Your situation is exactly what he second functionality is intended for, and the attribute 'src' is not special.
http://api.jquery.com/attr/