简体   繁体   中英

Getting text from <td> element using jQuery

if (document.getElementById("td1").innerHTML == "word"){
      $("td:first").html("another word");
}

I just want to check if this have this text .

You mean

if($('#td1').text() === "word"){
   $("td:first").html("another word");
}

this matches <div id=td1>word</div>

$("#td1:contains('word')").html("another word");

测试

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