I have a set of links like so
<a class="colorBox" href="#" title="#0676B3"></a>
<a ...
<a ... these are similar links with the title containing the color value
<a ...
My goal is to use jQuery to grab the value of the title attribute and plug that into the background with .css().
My latest attempt is this:
$(document).ready(function(){
$('a.colorBox').find().attr('title',function(){
var color = (this);
$('a.colorBox').css('background',color);
});
});
of coarse this does nothing but return an error. I'm sure it's because you cant have a callback in the .attr(). I can select the value easily but how do i store it into a variable? and how would you make the variable change to the next links title value and use that? with the .each() but how?
I am learning still so any code examples would be great or if there is an API function i am not aware about please let me know
thanks