鍍金池/ 問答/PHP  網(wǎng)絡(luò)安全  HTML/ 用js或php按一定規(guī)律去替換鏈接地址

用js或php按一定規(guī)律去替換鏈接地址

<html>
<body>
    <div class="top">
        <a class="zzz" >aaaa</a>
        <a class="xxx" >bbbb</a>
        <a class="ccc" >cccc</a>
    </div>
    <div class="content">
        <a class="ppp" >dddd</a>
        <a class="mmm" >eeee</a>
        <a class="kkk" >ffff</a>
    </div>
    <div class="qw-list">
        <a class="ft-item" >gggg</a>
        <a class="ft-item" >hhhh</a>
        <a class="ft-item" >iiii</a>
    </div>
</body>
</html>

要求說明:鏈接中的主域名abc.com是統(tǒng)一的,要求按照主域名是abc.com,并且類class="ft-item"一樣的所有標(biāo)簽中的href網(wǎng)站替換為http://www.opq.com,其他不同類名的a標(biāo)簽href鏈接不變。最好是用js實現(xiàn),或者是php。

回答
編輯回答
夕顏

$('.ft-item').each(function(){
$(this).attr('href','http://www.opq.com/'+$(this).attr('href').split('/').pop());
})
如果沒有其他特殊情況

2017年11月1日 12:38