0

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

ndequeker
  • 7,932
  • 7
  • 61
  • 93
blaize9
  • 28
  • 1
  • 6

3 Answers3

3
$('time').html(function(i, v){
    return v.replace(/(\d)/g, '<img src=$1.jpg />');
});

Here's the fiddle: http://jsfiddle.net/FtfkK/

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
1
var number = 5;
$('#myImage').attr('src', 'my_image_path/' + number + '.jpg');
Shomz
  • 37,421
  • 4
  • 57
  • 85
0

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?

Community
  • 1
  • 1
Matt Tew
  • 1,581
  • 1
  • 9
  • 15