Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

javascript - How do i remove <tbody> tags from an HTML table?

Just like the title says: I need a way to remove the tags from nested HTML tables. Any suggestions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't disembody HTML tables.

If you're looking to get rid of superfluous <tbody></tbody> tags in an HTML string, do a string replacement:

var html = '<table><tbody>...</tbody></table>'.replace(/</?tbody>/g, '');
$(html).appendTo('body');

But browsers are still going to put the table rows in a table body when rendering the HTML anyway.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...