Cargue el contenido de div en un div diferente

I have a value which is created around the middle of a page and I want to show it in the header...

Entonces, tengo lo siguiente:

<div id=lines style=display:none;><? echo ($line_no-1); ?></div>

Now, I want to load that value ($line_no-1) into a div in the header. So as you can see I store it into a div, turn off the display, and then use the following to try to load it into the div above

<script type="text/JavaScript">
        $("#lines2").load("/ #lines");

It simply doesn't work and I think I've tried every combination now

What I'd rather do is simply load the variable into the div above but have searched and searched for a way to do this with no luck.

preguntado el 30 de enero de 12 a las 19:01

this looks very sloppy to me, but why aren't you doing something simple like $('#lines2').html($('#lines').html()); ? -

2 Respuestas

To merely reproduce the text from the lines div en el lines2 div:


Respondido el 30 de enero de 12 a las 23:01

.load means something else. Try this:

<script type="text/javaScript">

If you want to append it instead, do:


Respondido el 30 de enero de 12 a las 23:01

you can actually use .text() en lugar de .html(), since it's only a number (no html structure) - o

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.