将文本附加到属性而不是替换它? [英] Append text to an attribute rather than replacing it?

查看:77
本文介绍了将文本附加到属性而不是替换它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些类的所有元素的标题属性中附加一些文本.

I want to append some text to the title attribute of all elements of a certain class.

推荐答案

在这种情况下,$(this)不是$('.theclass')的元素.也许您想使用 each :

In that context, $(this) is not the element of $('.theclass'). Maybe you want to use each:

$('.theclass').each(function() {
    $(this).attr("title", $(this).attr("title") + "Appended text.");
});

这篇关于将文本附加到属性而不是替换它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆