简体   繁体   中英

<td><span>course</span>English</td> how to get TD value NOT span value

I have span inside a td :

<td><span>course</span>English</td>

so when I get the td value, it returns all text with the span . How can we get only the td value? When I'm sending mail, all the text comes in the mail.

Like this:

Course           Mark       Scale Mark      Units   
CourseEnglish    Mark97     Scale Mark92    Units 2 

I want it like this:

Course           Mark       Scale Mark      Units
English          97         92              2   

You can use the following snippet in jquery

var removeText=$("td").find("span").text();
console.log($("td").text().replace(removeText,''));

在纯JavaScript中,您会像

 console.log(document.getElementsByTagName('td')[0].lastChild.data); 
 <table><tr><td><span>course</span>English</td></tr></table> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM