1
I have a simple scheme to get to class .ativo
and remove it and add the class .block
then find the id #banner1
and adds the class .ativo
and removes the class .block
Only it’s not working, look there :
$(".botao1").click(function() {
$('.ativo').removeClass('ativo').addClass('block').find($("#banner1")).addClass('ativo').removeClass('block');
});
Does anyone know why ?
The element with the id
banner1
is within element with the classativo
? If not, thefind
will not return any result.– mgibsonbr
Place the HTML as well
– Papa Charlie
@mgibsonbr, how to locate id outside the class ?
– Alan PS
I put an example in jsfiddle!!
– Alan PS
If you relate botao1 with banner1, botao2 with banner2... because the use of find? Remove
closest
button2– Papa Charlie
@Papacharlie, but the result won’t be the same?
– Alan PS
Your problem is not with changing class? You are making buttons to change the image and description, it is not?
– Papa Charlie
@Papacharlie, this! This button1 is to return to the first image and description. the 2 to 2nd, etc...
– Alan PS