user1746582
user1746582

Reputation: 569

Using Twitter Bootstrap glyphicons in javascript

Does anyone know how I can use a Twitter Bootstrap glyphicons to replace the image covered in the following example in my javascript (.js) file:

var $img = $('<img class="child-opener-image" src="../img/sample.png" title="text here" />');

in HTML I would just use the following as an example:

<i class="icon-search icon-white"></i>

though not sure how to include this in the javascript example above.

Any ideas?

Upvotes: 1

Views: 1663

Answers (1)

Rich Bradshaw
Rich Bradshaw

Reputation: 72985

Use:

$('<i class="child-opener-image icon-search icon-white"></i>');

The image is actually a sprite sheet, so it's kinda fiddly to use it otherwise - you'd need to set the correct background-position etc, so why not just use the class that already has that info!

Upvotes: 1

Related Questions