jQuery: The Write Less, Do More JavaScript Library

 « Return to Thread: Replace div with another div

Re: Replace div with another div

by CoffeeAddict :: Rate this Message:

Reply to Author | View in Thread


Charlie, I just plan on using an ID or class that's already in that
div to reference it.  For example:
<div class="jcarousel-prev jcarousel-prev-horizontal jcarousel-prev-
disabled jcarousel-prev-disabled-horizontal" style="display: block;"
disabled="true"/>

why couldn't I do something like $(".jcarousel-prev jcarousel-prev-
horizontal jcarousel-prev-
disabled jcarousel-prev-disabled-horizontal").replaceWith('<div
class="jcarousel-prev jcarousel-prev-horizontal" style="display:
block;" disabled="false"/>');


On Jul 2, 9:04 am, Charlie <charlie...@...> wrote:

> one problem you'll likely run into completely replacing that div
> even though the html and classes will fit in with the carousel you could have problems due to no events attached to new div from document ready
>  Giovanni Battista Lenoci wrote:
> 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

 « Return to Thread: Replace div with another div