I'm hand-maintaining an HTML document, and I'm looking for a way to automatically insert a link around text in a table. Let me illustrate:
<table><tr><td class="case">123456</td></tr></table>
I would like to automatically make every text in a TD with class "case" a link to that case in our bug tracking system (which, incidentally, is FogBugz).
So I'd like that "123456" to be changed to a link of this form:
<a href="http://bugs.example.com/fogbugz/default.php?123456">123456</a>
Is that possible? I've played with the :before and :after pseudo-elements, but there doesn't seem to be a way to repeat the case number.
Not possible with CSS, plus that's not what CSS is for any way. Client-side Javascript or Server-side (insert language of choice) is the way to go.
You could have something like this (using Javascript). Inside
<head>
, haveAnd then at the end of
<body>
I've tested it, and it works fine.
I don't think it's possible with CSS. CSS is only supposed to affect the looks and layout of your content.
This seems like a job for a PHP script (or some other language). You didn't give enough information for me to know the best way to do it, but maybe something like this:
Then later in your document:
And if you want an .html file, just run the script from the command line and redirect the output to an .html file.
I know this is an old question, but I stumbled upon this post looking for a solution for creating hyperlinks using CSS and ended up making my own, could be of interest for someone stumbling across this question like I did:
Here's a php function called 'linker();'that enables a fake CSS attribute
for an #id defined item. just let the php call this on every item of HTML you deem link worthy. the inputs are the .css file as a string, using:
and the #id of the corresponding item. Heres the whole thing:
this could probably be improved/shortened using commands like .wrap() or getelementbyID() because it only generates the
<a href='blah'>
portion, but seeing as</a>
disappears anyway without a opening clause it still works if you just add them everywhere :DNot in a manner that will work across browsers. You could, however, do that with some relatively trivial Javascript..
You can apply it with something like
onload = makeCasesClickable
, or simply include it right at the end of the page.here is a jQuery solution specific to your HTML posted:
in essence, over each .case element, will grab the contents of the element, and throw them into a link wrapped around it.