Reputation: 28
So basically what I want to do is use jQuery to replace numbers with images.
I want to replace 5hr 53min with images so if there is a 5 then it will display 5.jpg, and the same thing with the 3 to replace that and display 3.jpg.
Here is an example of what I want to do: http://pastehtml.com/view/c9of5gm15.html
Upvotes: 0
Views: 1250
Reputation: 219936
$('time').html(function(i, v){
return v.replace(/(\d)/g, '<img src=$1.jpg />');
});
Here's the fiddle: http://jsfiddle.net/FtfkK/
Upvotes: 3
Reputation: 1621
You will want to draw your numbers using a HTML canvas, and then create a data URL
See Capture HTML Canvas as gif/jpg/png/pdf?
Upvotes: 0
Reputation: 37701
var number = 5;
$('#myImage').attr('src', 'my_image_path/' + number + '.jpg');
Upvotes: 1