2010-08-23 35 views
0

在下面的標記中,我想查找標記並希望在所有標記中添加rel =「bbbb」後添加一個常見的類類「AAA」。在運行時使用jquery添加一個普通的rel和一個類

我的HTML標記

<div class="gallery galleryid-4" id="gallery-1"> 
      <dl class="gallery-item"> 
      <dt class="gallery-icon"> 
       <a title="54-Valentine-Wallpapers" href=""><img width="150" height="150" title="54-Valentine-Wallpapers" alt="54-Valentine-Wallpapers" class="attachment-thumbnail" src="http://linkspire.rtcamp.info/wp-content/uploads/2010/08/54-Valentine-Wallpapers-150x150.jpg"></a> 
      </dt></dl> 
      <dl class="gallery-item"> 
      <dt class="gallery-icon"> 
       <a title="27320_car-wallpapers19" href=""><img width="150" height="150" title="27320_car-wallpapers19" alt="27320_car-wallpapers19" class="attachment-thumbnail" src="http://linkspire.rtcamp.info/wp-content/uploads/2010/08/27320_car-wallpapers19-150x150.jpg"></a> 
      </dt></dl> 
      <dl class="gallery-item"> 
      <dt class="gallery-icon"> 
       <a title="bugatti-v16-turbo-wallpapers" href=""><img width="150" height="150" title="bugatti-v16-turbo-wallpapers" alt="bugatti-v16-turbo-wallpapers" class="attachment-thumbnail" src="http://linkspire.rtcamp.info/wp-content/uploads/2010/08/bugatti-v16-turbo-wallpapers-150x150.jpg"></a> 
      </dt> 
      </dl> 

    </div> 

PS。

+0

什麼標記你想的類和RELS增加? – 2010-08-23 10:06:43

+0

我想添加一個類和一個相對這樣的 Soarabh 2010-08-23 10:08:37

+1

你不應該使用* that *標記爲你正在做的事情。定義列表絕對不是你需要的。 http://reference.sitepoint.com/html/dl – 2010-08-23 10:12:31

回答

1

一個模糊的答案,你的含糊不清的問題

$('gallery-1 TAG-NAME-HERE').addClass('AAA'); 

$('gallery-1 *').attr('rel', 'BBB') 
相關問題