我想附加此HTML代码
<script type="text/javascript" src="/feeds/posts/default/-/+++++?published"></script>
到这个div内容
<div class="content"><h>Arts</h></div>
并用<h></h>
最后结果将是
<div class="content"><h>Arts</h><script type="text/javascript" src="/feeds/posts/default/-/Arts?published"></script></div>
答案 0 :(得分:1)
var headerText = $(".content").text();
var script = '<script type="text/javascript" src="/feeds/posts/default/-/' + headerText + '?published"></scr' + 'ipt>';
var newText = '<div class="concent"><h>' + headerText + '</h>' + script + '</div>';
$(".content").replaceWith(newText);
答案 1 :(得分:0)
给它一个id
<script id="myscript" type="text/javascript" src="/feeds/posts/default/-/+++++?published"></script>
然后
var sauce = $('#myscript').attr('src');
$('#myscript').attr('src', sauce.replace("+++++", $('h').text()));
$('#myscript').appendTo($('div.content'));
的示例