0

I've been trying to change a text of a td element however I am not able to make it work:

http://jsfiddle.net/9HkWH/

What could be wrong in that fiddle?

Actually this is just my first step to do my actual goal that is to prettify a date using:

http://timeago.yarp.com/

Updated:

Where I need to do:

$(function() {
   $('td[kind="date"]').html("Hello?");
})
quarks
  • 33,478
  • 73
  • 290
  • 513

3 Answers3

4

There are multiple problems

  1. Your script has a syntactical error, the quotes are not properly escaped
  2. Your html is not valid, there is no opening/closing <table tags
  3. Selector p[kind=date] is invalid since there is no p element, a td has the attribute kind="date".

So

$(function() {
   $('td[kind="date"]').html("test");
})

Demo: Fiddle

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
1

First,you write the wrong selector,there is not 'p' element,your should try

$("td[kind='date']").html("test");

Second,the quotation marks in selector should be single not double.

Last and most important,your html code missed 'table' tag,so the html will render as text not a table,that's why your selector will not work even you change the selector by other's advices.

Check this Demo,it works fine.

Jarvan
  • 1,135
  • 8
  • 22
0

Can you please refer the below code.

function changeText() {
    $("#demoTable td").each(function () {
       $(this).html().replace("8: Tap on APN and Enter <B>www</B>", "");
    }
}

Replace text inside td using jQuery

Community
  • 1
  • 1
SivaRajini
  • 7,225
  • 21
  • 81
  • 128