Change text from a div inside the fancybox

Asked

Viewed 94 times

0

I have a popup using Fancybox, inside it I have a div, I need to change dynamically using Javascript the text of it. I am using the following code at the click of a button call:

$('#id-da-div').html('Novo texto');

This simple code works anywhere within my site, but when the div is within the Fancybox does not work. It does not give any error, it simply does not update the html inside the div.

It must be something from Fancybox, I need to solve by putting a counter inside the popup.

Thank you.

  • Try selecting the element with the browser panel.

  • I already did, I inspected the element and the html of the div remains static, even without showing errors in the console.

1 answer

0

Select the element inside the Fancybox:

  1. Press F12 to open "developer tools" in the browser.
  2. Select the element that has the text to be changed.
  3. In the source code shown on the panel, right-click on the element.
  4. In the menu select "Copy > Copy selector" and paste the copied code into the jQuery selector: $('CÓDIGO_COPIADO').text('Novo texto');

inserir a descrição da imagem aqui

  • Copy Selector returns me #id-da-div which is actually the id of my div, which I defined. I already have her id, even using it the text is not changed.

  • So I don’t understand. You want to change a Fancybox DIV or one that you made yourself?

  • I did, she’s inside the fancybox, she’s part of the content I uploaded into the fancybox. In fact, it can be any element within Fancy, be it a text or div, I can’t change any information using javascript of the elements within Fancy.

  • Strange. Is this id not duplicated?

  • Can’t go wrong when you select the div by the copy selector.

  • Do a search for this ID in the source code. There can be no more than 1.

  • I’ll run one more analysis and post back. Thank you.

  • I’ve already checked everything, there are no duplicates, in the source code of the page the div is being shown normally. I have a lot of experience with web development, but this time I don’t see what could be wrong.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.