jQuery: The Write Less, Do More JavaScript Library

Replace div with another div

View: New views
9 Messages — Rating Filter:   Alert me  

Replace div with another div

by CoffeeAddict :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

Re: Replace div with another div

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

Reply to Author | View Threaded | Show Only this Message


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


Re: Replace div with another div

by Charlie Tomlinson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Re: Replace div with another div

by CoffeeAddict :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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

Re: Replace div with another div

by CoffeeAddict :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


>>>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

I guess I don't understand.  If I'm just replacing the code with code
that would show up if the button was enabled, it still has valid
structure for the carousel .js library to manipulate or reference.

On Jul 2, 9:42 am, expresso <dschin...@...> wrote:

> 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

Re: Replace div with another div

by CoffeeAddict :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I want to replace it with <div class="jcarousel-prev jcarousel-prev-
horizontal" style="display:
block;" disabled="false"/> which is what the carousel code replaces it
with anyway when the button IS enabled..I just viewed the source to
see that.

On Jul 2, 9:42 am, expresso <dschin...@...> wrote:

> 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

Re: Replace div with another div

by ricardobeat :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Are you sure you need to do that? The button is disabled when you get
to the first/last item, if you add new items following the documented
ways it is completely unnecessary: http://sorgalla.com/projects/jcarousel/#Dynamic-Content-Loading

-- ricardo

On Jul 2, 11:45 am, expresso <dschin...@...> wrote:

> I want to replace it with <div class="jcarousel-prev jcarousel-prev-
> horizontal" style="display:
> block;" disabled="false"/> which is what the carousel code replaces it
> with anyway when the button IS enabled..I just viewed the source to
> see that.
>
> On Jul 2, 9:42 am, expresso <dschin...@...> wrote:
>
> > 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

Re: Replace div with another div

by CoffeeAddict :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Richard, I have a reason for wanting to do this other than the default
behavior.  Anyhow, I got this working without having to do any of this
in the end!

On Jul 2, 7:59 pm, Ricardo <ricardob...@...> wrote:

> Are you sure you need to do that? The button is disabled when you get
> to the first/last item, if you add new items following the documented
> ways it is completely unnecessary:http://sorgalla.com/projects/jcarousel/#Dynamic-Content-Loading
>
> -- ricardo
>
> On Jul 2, 11:45 am, expresso <dschin...@...> wrote:
>
> > I want to replace it with <div class="jcarousel-prev jcarousel-prev-
> > horizontal" style="display:
> > block;" disabled="false"/> which is what the carousel code replaces it
> > with anyway when the button IS enabled..I just viewed the source to
> > see that.
>
> > On Jul 2, 9:42 am, expresso <dschin...@...> wrote:
>
> > > 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

Re: Replace div with another div

by Cesar Sanz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


It is always a good idea to put the way you achieve your results.. Maybe
other people is looking
the same as you..

We must to learn not being so selfish!
----- Original Message -----
From: "expresso" <dschinkel@...>
To: "jQuery (English)" <jquery-en@...>
Sent: Thursday, July 02, 2009 8:52 PM
Subject: [jQuery] Re: Replace div with another div



Richard, I have a reason for wanting to do this other than the default
behavior.  Anyhow, I got this working without having to do any of this
in the end!

On Jul 2, 7:59 pm, Ricardo <ricardob...@...> wrote:

> Are you sure you need to do that? The button is disabled when you get
> to the first/last item, if you add new items following the documented
> ways it is completely
> unnecessary:http://sorgalla.com/projects/jcarousel/#Dynamic-Content-Loading
>
> -- ricardo
>
> On Jul 2, 11:45 am, expresso <dschin...@...> wrote:
>
> > I want to replace it with <div class="jcarousel-prev jcarousel-prev-
> > horizontal" style="display:
> > block;" disabled="false"/> which is what the carousel code replaces it
> > with anyway when the button IS enabled..I just viewed the source to
> > see that.
>
> > On Jul 2, 9:42 am, expresso <dschin...@...> wrote:
>
> > > 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