使用jquery在运行时添加公共rel和类

时间:2010-08-23 10:02:19

标签: jquery html

在下面的标记中,我想找到标签,并希望在所有标签中添加rel =“bbbb”之后添加一个公共类“AAA”。

我的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。

1 个答案:

答案 0 :(得分:1)

对你的模糊问题的模糊回答

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

$('gallery-1 *').attr('rel', 'BBB')