lundi 16 mars 2015

accessing different elements of a button


Vote count:

0




I have a button:



<a href="#" id="form-submit" class="btn btn-primary btn-lg ladda-button"
data-style="contract" data-size="l"><span class="ladda-label">TESTLABEL</span></a>


and I'm trying to access the text inside of it: TESTLABEL through an IF statement. I can change the text like this:



$('#form-submit').text('GO').button("refresh");


but this if/else statement runs the first set of code each time - never the else if part.



console.log($('#form-submit').text());

if ($('#form-submit').text('TESTLABEL')) {
$('#form-submit').text('GO').button("refresh");
} else if ($('#form-submit').text('GO')) {
//do other code...
}


When I click the button - the text is TESTLABEL, and that changes to GO once I click. When I click again, the console.log tells me that this button's text is GO, but the first if statement still runs as though its text were TESTLABEL. What am i doing wrong?



asked just now







accessing different elements of a button

Aucun commentaire:

Enregistrer un commentaire