1

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?

4
  • 1
    Why not $('<i class="icon-search icon-white"></i>'); ? Commented Jan 9, 2013 at 11:15
  • hi Rich, thanks for your suggestion. How can i also include the "child-opener-image" class in the example above? This is needed by the plugin i am using. Commented Jan 9, 2013 at 11:22
  • 1
    Hi, just got it working was easier than I thought: $('<img class="child-opener-image icon-pencil" ...) Many thanks Rich :) Commented Jan 9, 2013 at 11:29
  • Cool - I've added as an answer instead then so you can accept it :) Commented Jan 9, 2013 at 11:40

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

1 Comment

+1, just edited your answer with what I actually included. a minor change for my purpose. thanks again :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.