最近需要將最近更新的部分內(nèi)容刪除,只要標(biāo)題中包括百度與360的都給刪除了,這樣用戶就看不到了
1 2 3 4 5 6 7 8 9 10 11 | function notxt(){ '刪除指定位置超鏈接中含有百度與360的標(biāo)題 var notext = [' 百度 ',' 360 ']; $(' #news ul li').each(function(){ var mytext = $( this ).find('a').text(); for ( var n=0; n<notext.length; n++) { if (mytext.indexOf(notext[n]) != -1){ $( this ).remove(); } } }) |
將news ul li換成自己的就可以了,這個(gè)代碼是基于jquey的,原生js要稍微代碼要多點(diǎn)。