May 5, 2009

jQuery, Selecting the Previous Element With Filtering

Recently I was looking for a solution to this problem. My HTML looked like this:

<a class="file" href="download/876243.pdf">876243.pdf</a>
<a class="tagcontrol" id="876243.pdf">tag</a>
<a class="tag" href="index.php?tag=test">test</a>
<img class="delete" title="remove this tag" src="img/tag-del.png" />

The idea being that you would click the image with the “delete” class and submit an ajax call to delete the tag for that file in a Folksonomy [...]