jQuery - setting an element's text only without removing other element (anchor)

前端 未结 3 1663
时光说笑
时光说笑 2020-12-08 10:00

I have an element like this:


  anchor
  [ some text ]

And i need to set it\'s text in jQuery, wit

3条回答
  •  时光取名叫无心
    2020-12-08 10:42

    Without changing markup:

    Live Demo

    var anchor = $('td').find('a').clone();
    $('td').text('{ some other text }').prepend(anchor);
    

提交回复
热议问题