0

私は以下のようないくつかの要素を持っています:

<div id="shareswrapper">
    <div id="41">
           some content blah blah blah...
    </div>
</div>

以下のdivを追加する必要がありますshareswrapper

    <div id="1751">
           Some new content here!!!!
    </div>

出力は次のようになります。

<div id="shareswrapper">
    <div id="1751">
           Some new content here!!!!
    </div>
    <div id="41">
           some content blah blah blah...
    </div>
</div>

私は最初の子供を使いましたが、成功しませんでした。.before()共有ラッパー内にどのdivがあるかわからないため、この方法は機能しません。
なにか提案を?

4

2 に答える 2

6

プリペンドを使用..

$('#shareswrapper').prepend('<div id="1751">Some new content here!!!!</div>');
于 2012-06-25T15:23:43.353 に答える
0

あなたは両方とも正しい軌道に乗っています。それらを連鎖させる

$('#shareswrapper:first-child').before("injection content")
于 2012-06-25T15:27:58.793 に答える