Question

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?

Was it helpful?

Solution

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!

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