Question

I am trying to implement a tag cloud like Amazon.co.uk see here. my currenct javascript is like this

var tags = jq.getJSON(baseUrl + '/ajax/populartags', null, function(json){
    //create list for tag links
    jq("<p>").attr("id", "popularTagsList").appendTo("#tagCloud");
    //create tags
    jq.each(json, function(i, val) {
        //create link
        a = jq("<a>").text(val.Tag).attr({title:"See all pages tagged with " + val.Tag, href:baseUrl + '/item/tag/' + val.Tag});
        a.css("fontSize", (val.Count / 10 < 1) ? val.Count / 10 + 1 + "em": (val.Count / 10 > 4) ? "4em" : val.Count / 10 + "em");

        //add to list
        a.appendTo("#popularTagsList");
    });
});

is it possible to add ligten/darken functionality to this code?

Was it helpful?

Solution

I think the approach to take would be to adjust the color. In order to "lighten" the color, increase the value for each of RGB components of that color. To "darken" it, decrease the values. If that doesn't make sense or if you'd like a detailed code sample, post a comment and I'll get back with an update shortly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top