将某些文本从一个div复制到另一个div [英] Copy certain text from one div into another div
问题描述
我希望能够将某些文本从一个div复制到另一个div.
I want to be able to copy certain text from one div into another div.
文本是从Wordpress插件生成的,并且会生成2个不同的div,其中以下类别1称为.voting inactive,第二类称为.voting.
The text is generated from a Wordpress Plugin, and it generates 2 different divs, with the following classes 1 called .voting inactive and the second one called .voting.
生成的文本是基于评级的,它将类似于:评级4.5/5,我只想进行4.5投票或生成的任何投票,然后将其复制到div中即可很好地显示结果.
The text generated is rating based is it will look something like: Rating 4.5/5, i ONLY want to take the 4.5 or whatever vote is generated and copy that into a div to display the result nicely.
任何帮助都会很棒.
推荐答案
我与@Starx在一起.但要更加清楚一点:
I'm with @Starx on this one. But just to be a little more clear:
<div>
Rating
<span id="average">4.5</span>/
<span id="highest_possible">5</span>
</div>
<div id="target">
<!-- This could be any element -->
</div>
然后是JS
$(document).ready(function() {
$("#target").html($("#average").html());
});
希望有帮助!
这篇关于将某些文本从一个div复制到另一个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!