Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,162,888 members, 7,851,995 topics. Date: Thursday, 06 June 2024 at 11:20 AM

Please Help With Jquery Code - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Please Help With Jquery Code (578 Views)

Any HELP Here? Using Jquery And Angularjs Ng-view / I Need Help For This Chained Select Jquery! / For N28,000 Can Someone Develop A Website Consisting - Jquery, AJAX & Bootstrap? (2) (3) (4)

(1) (Reply) (Go Down)

Please Help With Jquery Code by emilykel(m): 12:51pm On May 15, 2015
Please can you help me check this code??..
The idea is to change the text on the button when it is clicked...
<input type="button" id="toggle" value="change"/>
$('#toggle').on('click',function(){
var text=$('#toggle').text();
if(text=='change'){
$('#toggle').text('text changed');
}else if(text=='change'){
$('#toggle').text('change');
}
I also tried...
$('#toggle').attr('value');
But it still didn't work
So tell me why its not working
and am running the code on my android phone so could that also be the reason ??
Re: Please Help With Jquery Code by Nobody: 1:17pm On May 15, 2015
this should work

$('#toggle').click(function () {
$(this).attr("value","new text" ) ;
});


this damned emoticons

1 Like

Re: Please Help With Jquery Code by emilykel(m): 1:44pm On May 15, 2015
I tried that too ooo
Re: Please Help With Jquery Code by Nobody: 2:12pm On May 15, 2015
emilykel:
I tried that too ooo
it is working bro,did you even try it,because you saw attr in the code ?
you used --- attr|("value"wink


i used
attr("value","new text" ) ....... did you link to the jquery lib before writing the codes ?
Re: Please Help With Jquery Code by fattbabakay(m): 2:56pm On May 15, 2015
Jregz:

it is working bro,did you even try it,because you saw attr in the code ?
you used --- attr|("value"wink


i used
attr("value","new text" ) ....... did you link to the jquery lib before writing the codes ?
D problem can be as simple as dat @ bolded..... cry cry cry
Re: Please Help With Jquery Code by emilykel(m): 2:57pm On May 15, 2015
I knew it was working but maybe its cuz am running it on my android and not on computer...tanx
Re: Please Help With Jquery Code by emilykel(m): 3:01pm On May 15, 2015
yes I linked it ooo...av been running some jquery codes that's the only one not working...
Re: Please Help With Jquery Code by Craigston: 3:59pm On May 15, 2015
emilykel:
Please can you help me check this code??..
The idea is to change the text on the button when it is clicked...
<input type="button" id="toggle" value="change"/>
$('#toggle').on('click',function(){
var text=$('#toggle').text();
if(text=='change'){
$('#toggle').text('text changed');
}else if(text=='change'){
$('#toggle').text('change');
}
I also tried...
$('#toggle').attr('value');
But it still didn't work
So tell me why its not working
and am running the code on my android phone so could that also be the reason ??

What about that? Does it log errors to the console?
Re: Please Help With Jquery Code by thewebcraft(m): 6:19pm On May 15, 2015
emilykel:
Please can you help me check this code??..
The idea is to change the text on the button when it is clicked...
<input type="button" id="toggle" value="change"/>
$('#toggle').on('click',function(){
var text=$('#toggle').text();
if(text=='change'){
$('#toggle').text('text changed');
}else if(text=='change'){
$('#toggle').text('change');
}
I also tried...
$('#toggle').attr('value');
But it still didn't work
So tell me why its not working
and am running the code on my android phone so could that also be the reason ??

You where using .text() value instead of attribute value that's why it didnt work
Use this to toggle the value of the button every time you click
$('#toggle').click(function() {
if ($(this).attr('value') == "change" ){

$(this).attr('value', 'another change');

}

else {
$(this).attr('value', 'change');
}
});

(1) (Reply)

Wp Touch Pro Urgently Needed. / The 'reddit Revolt' That Led To Ellen Pao's Resignation Is Bad For The Internet / Sites Every Nigerian Female Should Visit

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.