jQuery: The Write Less, Do More JavaScript Library

 « Return to Thread: Replace div with another div

Re: Replace div with another div

by Giovanni Battista Lenoci-2 :: Rate this Message:

Reply to Author | View in Thread


expresso ha scritto:

> I'm trying to figure out how I'd explicitely change out a div.
>
> Lets say this div is in the page.  I guess first I'd have to verify if
> it's in the page:
>
> <div class="jcarousel-prev jcarousel-prev-horizontal jcarousel-prev-
> disabled jcarousel-prev-disabled-horizontal" style="display: block;"
> disabled="true"/>
>
> And if it is, I want to remove it and add this in the same place:
>
> <div class="jcarousel-prev jcarousel-prev-horizontal" style="display:
> block;" disabled="false"/>
>
> I have not a clue how to do this.
>  
If give a unique id to the div (or you have a rule to get it, for
example $('#mycontainer > div'));

You can do:

$('#id').replaceWith('<div>my newmarkup!</div>');

If the selector doesn't return nothing then nothing will be replaced.


Bye

--
gianiaz.net - web solutions
via piedo, 58 - 23020 tresivio (so) - italy
+39 347 7196482

 « Return to Thread: Replace div with another div