0

I have done a search on Google and surprisingly cannot find a relevant answer.

What I am trying to do is hook onto around 6 TD id's (id="1234price", id="2345price" etc)

and change the text within that table cell for all of them to say coming soon rather than the various prices they currently show.

looking at jquery docs replacewith seems to replace the whole thing i.e it would remove the entire td as opposed to replacing the text contained within the td?

1
  • If you are looking up 6 ID's and want to replace them all with the same value, then its best to probably use classes. i.e add class="price" to your TD's and then use $('.price').text("coming soon"); or $('.price').html("coming soon"); [can checkout the difference] Commented Aug 7, 2013 at 8:16

2 Answers 2

1

Use the text method to set the text inside the elements. Example:

$('#1234price,#2345price').text("coming soon");
Sign up to request clarification or add additional context in comments.

1 Comment

well that was rather easy....I used html method instead as i wanted to use some html in it too.
0

Suppose text of td look like below

<td id="price123"><a href="#">tag hyperlink</a><p>p tag</p>text</td>

Use this line

$('#price123').contents().last()[0].textContent='50';

It keeps other HTML tags on td, and change the text on the last location. Demo Change text only

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.