-4

I have checked the classes and id's to make sure they call work, and console.log everything, but my text isnt changing? Is there anything obvious that I am missing here?

$('.clicker').click(function () {
    var currentId = '#' + $(this).parents('.parentClass').attr('id');

    $(currentId).find(".textContainer").text('changed 
    text');
});
Peeper
  • 362
  • 2
  • 3
  • 16

2 Answers2

0

I think you have confused .data() with .attr(). Use .data("id") or .attr("data-id") to get the data-id attribute of an element.

Take a look at this question for more info.

blackandorangecat
  • 1,246
  • 5
  • 18
  • 37
-1

Try with $(currentId).find(".textContainer").html('changed text'); that is use .html() instead of .text()

OPulido
  • 309
  • 2
  • 10