Icon only back button jQuery Mobile

2019-08-19 07:59发布

问题:

Within my jQuery Mobile page I programmatically set up my back button to appear on every page that is not the first page by using the following code <div data-role="page" data-add-back-btn="true" id="anid"> what this does is create a back button that have text in it saying back. however I do not want that I want the icon only.

How can this be done in jQuery Mobile

回答1:

Working example: http://jsfiddle.net/Gajotres/ygmWD/

$(document).on('pagebeforeshow', function () {
    $.mobile.activePage.find(".ui-header a.ui-btn-left").addClass("ui-btn-icon-notext");
    $.mobile.activePage.find(".ui-header a.ui-btn-left").removeClass("ui-btn-icon-left");
});


回答2:

You can do this.

$(document).on('pagebeforeshow', function () {
 $(this).find('a[data-rel=back]').buttonMarkup({iconpos: 'notext'});
});

Demo



回答3:

for me this one worked:

data-iconpos="notext"

Example:

<a href="#" data-icon="back" data-rel="back" title="Regresar" data-iconpos="notext"></a>