Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,346 members, 7,957,922 topics. Date: Wednesday, 25 September 2024 at 02:06 AM |
Nairaland Forum / Science/Technology / Webmasters / Please Help With Jquery Code (590 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)
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:it is working bro,did you even try it,because you saw attr in the code ? you used --- attr|("value" 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:D problem can be as simple as dat @ bolded..... |
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: 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: 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)
What Good Payment Gateway Can Be Used For Opencart System? / Enter If You Are A Good Website Designer / Facebook Opens Its First African Office In Johannesburg.. Nunu Ntshingila Heads.
(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. 26 |