获取元素内部的缩写

Get abbr inside element

本文关键字:缩写 内部 元素 获取      更新时间:2023-09-26

我有这个:

<th class="day-heading mon" scope="col">
  <abbr title="Lunes">L</abbr>
</th>

我需要访问缩写并更改内部HTML和标题。我该怎么做?我试着做。。。

jQuery('.day-heading mon > abbr');

但我不能从那里修改属性。

$("abbr")

$("abbr").attr("title","something")
$("abbr").html("stuff")

如果您想在<th class="day-heading mon" >内选择"缩写",请执行:

$("th.day-heading.mon abbr")

您可以使用.html()jQuery函数编辑所选元素的内部HTML,并使用.attr()jQuery函数来编辑其title属性。因此,你可以做:

$('.day-heading mon > abbr').attr("title", "HST")
$('.day-heading mon > abbr').html("Hubble Space Telescope")