₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,405 members, 8,421,761 topics. Date: Sunday, 07 June 2026 at 12:05 AM

Toggle theme

Please Help With Jquery Code - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersPlease Help With Jquery Code (712 Views)

1 Reply (Go Down)

Please Help With Jquery Code by emilykel(op): 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
Re: Please Help With Jquery Code by emilykel(op): 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 ? huh
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 ? huh
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(op): 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(op): 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):
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

Any HELP Here? Using Jquery And Angularjs Ng-viewI Need Help For This Chained Select Jquery!For N28,000 Can Someone Develop A Website Consisting - Jquery, AJAX & Bootstrap?234

Keyword Content WritingHow To Import Stuffs Online At Dead Cheap Prices & Resell For Big Profits.Best Unlimited Web Hosting Offer Ever