Skip to content
Advertisement

Replace old value with new value excluding the children

The initial text of A, B, C, D, and the number need to be removed in the frontend because I require it in the backend.

The HTML structure of table row is like this:

JavaScript

Before Input:

Before input

Current Output:

Current output

If you notice that the selected option is also not visible. Is it because of the $(window).load() ?

Required Output:

Required output

Code that I am using:

JavaScript

How can I make it so that it does not affect the <b> tag inside?

I used the above code for the steps heading with a different selector on the same page* and it worked because it did not have any children to alter.

I had to wrap it around $(window).load() so that the changes are applied after the table is loaded. $(document).ready() did not work with it. Not sure why?

Advertisement

Answer

(Edit: Modified to accommodate restated requirement in comment below.)

To strip “everything up to and including the ‘-‘” from the text of first column table cells while leaving the rest untouched:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement