0
<td width="100" align="center" id="5-0" class="c5 r0">
  <input type="hidden" value="3">Service Tax
  <span class="jexcel_arrow">
    <span id="jexcel_arrow"></span>
  </span>
</td>

How do i change 'Service Tax' string from jquery. 'Service Tax' string might get change in future so string can be anything which i want to replace.

Please note: We can't change the HTML structure.

  • 1
    How do you want it to change?? On `click`, `change` or `keyup`? Please be a bit more specific, and what should the `Service Tax` "change" to – Carsten Løvbo Andersen Oct 31 '18 at 08:38
  • Likely on load. – mplungjan Oct 31 '18 at 08:40
  • Check out https://stackoverflow.com/questions/11411937/changing-text-after-an-input-field – Carsten Løvbo Andersen Oct 31 '18 at 08:41
  • Change span from duplicate to td>input – mplungjan Oct 31 '18 at 08:42
  • @CarstenLøvboAndersen i simply want to change the text. Like On dropdown value change i want to change the 'Service Tax' value. – Palash Agrawal Oct 31 '18 at 08:44
  • What dropdown. Please create a [mcve] - this looks ore and more like an X/Y problem – mplungjan Oct 31 '18 at 08:47
  • 1
    Possible duplicate of [Changing text after an input field](https://stackoverflow.com/questions/11411937/changing-text-after-an-input-field) – Mohammad Oct 31 '18 at 08:49
  • @mplungjan simply need to change the text. Doesn't matter it's going to change on dropdown change or click event or keyup event. It's straight forward question. Need jquery to change the 'Service Tax' string without changing the html structure. We are having class and id if we need to catch the child item. – Palash Agrawal Oct 31 '18 at 08:54
  • @Mohammad better duplicate than https://stackoverflow.com/questions/6925088/get-the-text-after-span-element-using-jquery - which I repopened after marking as dupe. I cannot reclose because of that – mplungjan Oct 31 '18 at 09:08
  • @PalashAgrawal The duplicate suggested by Mohammad is an exact duplicate, easily found when [searching for the title of your question](https://www.google.nl/search?q=jquery+replace+text+after+input+field+site:stackoverflow.com) – mplungjan Oct 31 '18 at 09:10
  • @CarstenLøvboAndersen. shared link helped me. And now i have used below code to achieve the same. var inputTaxCol = $("#" + newtaxColId + " :input"); text = inputTaxCol[0].nextSibling.nodeValue, newText = text.replace(text, 'here'); – Palash Agrawal Oct 31 '18 at 09:23
  • 1
    @Mohammad .. Thanks to you as well – Palash Agrawal Oct 31 '18 at 09:28

1 Answers1

0

Thank you all for your guidelines.

Link(Changing text after an input field) shared in comment helped me. It's slightly different but resolved my problem. Below is the code to resolve it.

var inputTaxCol = $("#" + newtaxColId + " :input");
                  text = inputTaxCol[0].nextSibling.nodeValue,
                  newText = text.replace(text, 'my new text here');