jquery remove text partially

前端 未结 3 1221
逝去的感伤
逝去的感伤 2020-12-21 06:09

Can i use jQuery to remove part of a text within a div.

Like so:

Published May 18th 2011 - Approuved - Expire May 18 th 2
3条回答
  •  孤城傲影
    2020-12-21 06:50

    Try this:

    $(".entry").html(function(i, htm){
       return htm.split("-")[0];
    });
    

    html() can also have a function passed on to it if you want to process the html inside a node and then reset it.

    Here is a demo on jsfiddle : http://jsfiddle.net/nKJWn/

提交回复
热议问题