That's BAD html!! don't insist! :)

Just kidding.. you should switch over to classes or you'll eventually
face quirk after quirk.

--
Ariel Flesler
http://flesler.blogspot.com

On 12 mayo, 17:52, Hamish Campbell <[EMAIL PROTECTED]> wrote:
> Even though you can't use the id selector directly, you can still use
> the id as an attribute selector (works in IE7 anyway).
>
> $(document).ready(function(){
>    $('div[id=wrapper]').each(
>       function(i){
>          $(this).attr('id', $(this).attr('id')+'_'+(i+1))
>       }
>    );
>
> });
>
> On May 13, 8:16 am, Ariel Flesler <[EMAIL PROTECTED]> wrote:
>
>
>
> > > $(this).attr('class') should be $(this).attr('className')
>
> > Not necessarily :)
>
> > --
> > Ariel Fleslerhttp://flesler.blogspot.com
>
> > On 12 mayo, 08:58, "Richard D. Worth" <[EMAIL PROTECTED]> wrote:
>
> > > One minor correction to the sample code below. $(this).attr('class') 
> > > should
> > > be $(this).attr('className')
>
> > > - Richard
>
> > > On Mon, May 12, 2008 at 7:22 AM, andrea varnier <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > On 12 Mag, 12:31, quirksmode <[EMAIL PROTECTED]> wrote:
> > > > > Hi,
>
> > > > > I am dynamically generating html which looks like this:
>
> > > > since you're generating the html dynamically, I'd suggest you do it
> > > > server side (i.e. a for loop).
> > > > if that is not possible, change <div id="wrapper"> with <div
> > > > class="wrapper">, if you need the "wrapper" string, or simply <div>,
> > > > because having the same id over the page is definitely a bad thing :)
> > > > the a solution could be:
>
> > > > $('div').each(function(i){
> > > >    var $this = $(this);
> > > >    var the_id = $this.attr('class');
> > > >    $this.attr('id', the_id + '_' + i)
> > > > });
>
> > > > this would be zero-based. change to (i+1) to have them starting with
> > > > wrapper_1.
> > > > without the class, shorter:
> > > > $('div').each(function(i){
> > > >    $(this).attr('id', 'wrapper_' + i)
> > > > });
>
> > > > if those div's are inside something else (let's assume a <div
> > > > id="container_div">, you can add a context to the first selector, to
> > > > speed up the process:
>
> > > > $('div', '#container_div').each(function(i){
> > > >    var $this = $(this);
> > > >    var the_id = $this.attr('class');
> > > >    $this.attr('id', the_id + '_' + i)
> > > > });- Ocultar texto de la cita -
>
> > > - Mostrar texto de la cita -- Hide quoted text -
>
> > - Show quoted text -- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

Reply via email to