[jQuery] php printing jQuery

[jQuery] php printing jQuery


Greetings,
I'm familiar with php, and somewhat less familiar with Javascript/
jQuery. I have an error that seems simple, but I've tried everything I
can think of and am felling as though I've hit a brick wall. Any help/
suggestions would be greatly appreciated!
I have based my code off of this (working) example:
jQuery code:
$("#spanT a").click(function() {
$("#selectedItem").find("span:last").remove();
var foo = $(this).attr("title");
alert(foo);
});
html:
<span id="spanT"><a href="#" title="test2">test2</a></span>
This does the following: when you click on the link with title
"test2", the div with id="selectedItem" clears everything in the most
recently added span section (these are created dynamically via jQuery
+php) and alerts us with "test2" (the title of anchor within the
span).
This does not do what the above does (although I'd like it to!):
php:
$info = "(<a href=\\\"#\\\" title=\\\"add_watch\\\">watch</a> /
delete)<br />(I bought this!)";
echo " $(\"#snap".$snap['oid']."\").mouseover(
function() {
$(\"#selectedItem\").find(\"span:last
\").remove();
$(\"#selectedItem\").append($(\"<span id=\\
\"span".$snap['oid']."\\\">".$info."</span>\"));
});\n";
echo " $(\"#span".$snap['oid']." a\").click(function() {
$(\"#selectedItem\").find(\"span:last
\").remove();
var foo = $(this).attr(\"title\");
alert(foo);
});\n";
I thought that the "\\\" triple bars where a bit odd (and could very
well be what's causing this to break), but I get Javascript errors
(and no functionality at all) with out them.
Thanks a lot for any assistance!
Steve