Question

Im working in jquerymobile. I simply want to get string from label and convert it to int and then increment one. Here is what i have done in jsfiddle

my code is

<div data-role="footer" data-position="fixed" data-tap-toggle="false"> 
                <div data-role="navbar" data-mini="true" >
                    <a href="#" data-role="button" class="HeaderButton" data-icon="edit">&nbsp;</a>
                    <div data-role="controlgroup" data-type="horizontal" style="float: right;padding-right: 2%;">
                        <a href="#" data-role="button" id="aPreviousPage" onclick="PreviousPage()" data-icon="arrow-l" data-iconpos="left" data-theme="a">&nbsp;</a>
                        <a data-role="label" id="aPager" class="ui-disabled" style="padding:0;">2</a>

**<!--  (2)       i want 2 from id="aPager" but it gives me some string with it i m and jquerymobile is already using this  class '.ui-btn-text' -->**



 <a href="#" data-role="button" id="aNextPage"  onclick="NextPage()"   data-icon="arrow-r"  data-theme="a" data-iconpos="notext" data-inline="true">&nbsp;</a>
                    </div>
                </div><!-- /navbar -->
            </div><!-- /footer --> 
Était-ce utile?

La solution

string to int: parseint(x) where x = your string

increment/decrement int by 1: (x + 1) or (x - 1) where x = your starting int.

Combined: (parseint(x) + 1).

In your example: (parseInt($('.ui-btn-text').text()) + 1)

Edit* Additionally, in your jsfiddle, the line alert('NextPage function=' + parseInt(pager); is missing an ending ")" it should be alert('NextPage function=' + parseInt(pager));

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top