jQuery change child text

前端 未结 5 1334
不知归路
不知归路 2021-01-17 19:51

I have a jquery function that changes a text inside a element using a jquery \"text\" function. Inside this td element is child \"a\" tag like this.

5条回答
  •  囚心锁ツ
    2021-01-17 20:04

    If you have:

    
         text to change
     
    

    Then in your function you should have something like this:

    $("td.v3").children("a").text("new text");
    

    However, this will select all links that are direct children of tds with class .v3. Adding a .first() after children should help:

    $("td.v3").children("a").first().text("new text");
    

提交回复
热议问题