HTML:设置元素属性等于另一个元素属性

时间:2015-10-17 01:20:23

标签: jquery html selector

有没有办法将此元素标题<i title="" id='thei' class='fa fa-check-square-o'></i>设置为等于另一个元素innerHTML?

E.g。 <i title="(#tooltip).innerHTML" id='thei' class='fa fa-check-square-o'></i>

假装这是#tooltip:<p id="tooltip">Make this text a title of #thei</p>

1 个答案:

答案 0 :(得分:0)

尝试使用.attr(),将#thei "title"设置为#tooltip .html()

$("#thei").attr("title", $("#tooltip").html())

$("#thei").attr("title", $("#tooltip").html())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<p id="tooltip">Make this text a title of #thei</p>
<i title="" id='thei' class='fa fa-check-square-o'>thei</i>

相关问题