javascript - Get the content in the tag and assign it to the title?
大家讲道理
大家讲道理 2017-06-26 10:54:29
0
3
874
<p title="">嗨,你的title</p>

Assign "Hi, your title" to title

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
滿天的星座
var elem = document.querySelector("p");
elem.setAttribute("title", elem.innerText);
我想大声告诉你

$("p").attr("title",$("p").text());

给我你的怀抱

I don’t know what specific function you want, but if you want to assign a value, you can:

 <p title="" class="title">赋值啊啊啊啊</p>
    
    <script>
        let txt = $('.title').text();
        $('.title').attr('title',txt);
    </script>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template