12

I am looking to use the delete icon that is built-in to jQuery Mobile.

I know how to use buttons, you just use data-role - but I want to use it inside a plain old span or div.

Is there a way to do this?

Thanks

1
  • What have you tried so far? Have you tried to just change-out an <a /> tag for a <span /> tag? jsfiddle.net/rUPxQ/1 Commented Sep 20, 2012 at 1:00

4 Answers 4

14

Just upgraded to JQuery Mobile 1.4.0 -- Uh!... Nothing worked, until the following work-around:

<span class="ui-icon-delete ui-btn-icon-left " style="position:relative;" />

Note the class ui-btn-icon-left (you could use other ones -right, -top, -bottom, -notext, but this one seems to work the best). Most importantly, the style="position:relative" finally placed it within my container.

Happy coding...

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

1 Comment

Thanks! I'm also using 1.4.0 and was have trouble figuring this out.
11

You can just use a div with the classes specified, for example

<div class="ui-icon ui-icon-delete"></div>

Update:

The style-sheets for JQM have changed since this was first posted, you can get the same affect by adding the ui-btn-icon-notext class to your element (at least as of JQM 1.4.5). Additionally you might need to add a position:relative; to get it positioned correctly.

For example

  <span class="ui-btn-icon-notext ui-icon-delete" style="position:relative" />

Here's a link to the relevant API

4 Comments

@Haseeb I posted this for an earlier version of JQM, I updated my answer with an example for the current version.
style='position:relative' is important as Roman answered below
@ehrhardt perhaps, but at the time I guess it wasn't necessary. I answered this question in 2012.
@ehrhardt At any rate, I've updated my answer to include that information. Thanks for pointing it out.
0

How about using <span class="ui-icon ui-icon-delete ui-icon-shadow" style="display:block" /> or simply referenceing the ui-icon-delete class in your markup?

1 Comment

thanks but this doesnt seem to do anything. I know in regular jquery you can do that, but it doesnt work on mobile
0

add data-iconpos="notext"

Icon positioning:

http://demos.jquerymobile.com/1.1.2/docs/buttons/buttons-icons.html

Comments

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.