Rick Pasotto wrote:
The following code doesn't work. There are no errors reported but
nothing happens. What have I misunderstood and therefore gotten wrong?
Am I even on the right track to do what I want?
The dimensions.js and cluetip.js plugins have been loaded.
// have: <td>1420</td>
// want: <td><a class="ct" href="oneclub.php?club=1420"
rel="oneclub.php?club=1420">1420</a></td>
$(function() {
// get the first cell of each table row
$("tr+td").each(function(){
var clubnumber = $(this).text()
$(this).empty()
var url = '"oneclub.php?club=' + clubnumber + '"'
var h1 = ' href=' + url
var h2 = ' rel=' + url
$(this).html('<a class="ct"' + h1 + h2 + '>' + clubnumber + '</a>')
})
$(".ct").cluetip()
})
Your selector is wrong. "tr+td" would select any td that is following a
tr element.
Try: $('tr>td')
When in doubt it is quite useful to log the jQuery object into the
Firebug console for further inspection:
console.log( $('tr>td') );
CSS Selectors:
http://www.w3.org/TR/CSS21/selector.html
--Klaus