-1

嗨,我是这个网站的新手,我试图在我的论坛中获得一个标题,而不是在论坛中再次粘贴它 < div class="titleBar" >

所以基本上我需要的是一些代码,例如,可以获取该 div 中的内容

http://desiztv.com/index.php?threads/watch-colors-live-online-for-free.68/

标题是“免费在线观看颜色直播”我需要一些代码,我将在帖子中发布,它会自己获得标题,我可以在每个帖子中做到这一点,请帮助我谢谢 :)

4

1 回答 1

2

You could simply store the text value in a variable to use wherever you want...

<div id="mainTitle>Watch Colors Live Online For Free</div>

Using jQuery and JavaScript, we initialize a new variable called title.

var title = '';

Now as soon as your text has been inserted into your #mainTitle div element, you can retrieve the text content of that div using this -

title = $("#mainTitle").text();

Your title variable is then available for you to use anywhere you want to copy that text -

$("#someElement, #anotherElement, #yetAnotherElement").text(title);

All three elements -

<div id="someElement">Watch Colors Live Online For Free</div>
<div id="anotherElement">Watch Colors Live Online For Free</div>
<div id="yetAnotherElement">Watch Colors Live Online For Free</div>

will now contain the same text as the first #mainTitle element.

于 2012-10-22T17:08:01.087 回答