Link to home
Start Free TrialLog in
Avatar of rivkamak
rivkamakFlag for United States of America

asked on

simple jquery issue

I have a button on a div on my site.
When you click button A, then button B becomes visible by changing the class.

Then when button B has that new class if you click on it, something will happen. right now i'm trying to just log a console .
 
I don't know what I did wrong on the script. I am not getting an error, but no console log either.
I do see the button B has the correct class changed to it.
i tried also doing it with an id.
either one isn't logging anything.

what might be wrong?
  $(".pledgeBut").click(function(){
	  $(".thumbbuttonoff").removeClass('thumbbuttonoff').addClass('thumbbuttonon').attr('id', 'buttonon');
	   });
	  
$(".thumbbuttonon").click(function () {
console.log('button on');
$("#phonescreen1").toggle();
$("#phonescreen2").toggle();
});

$("#buttonon").click(function() {
	console.log("try two");
});

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

Try this because you set event on non existant element.
For example $("#notYetInThePage").click(function()
will not work

when : $(document).on("click", ".CheckIf_ImPresentInThePage", function() {
will work

  $(".pledgeBut").click(function(){
	  $(".thumbbuttonoff").removeClass('thumbbuttonoff').addClass('thumbbuttonon').attr('id', 'buttonon');
  });
	  
$(document).on("click", ".thumbbuttonon", function () {
    console.log('button on');
    $("#phonescreen1").toggle();
    $("#phonescreen2").toggle();
});

$(document).on("click", "#buttonon", function() {
	console.log("try two");
});

Open in new window

Post the code for the buttons.
Avatar of rivkamak

ASKER

I posted my code on top . you can see on the top of this page:
http://www.kars4kids.org/texting/index2.asp

Right now the document.on isn't working. it's telling me not a valid function.
Don't know what we're supposed to be clicking but leakim is probably right anyway.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But why would that happen.
at the time of the click my new id will work.
it's just not there at the time of document.load

How do people do these fancy animations? things happen later as id's and classes change
Did you tried my last suggestion ID: 39263895?