Re: GetElementByClass?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2010-04-03 at 09:33 -0600, Peter Pei wrote:

> > Sort of.
> >
> > Like I said, the folling will work:
> >
> > document.getElementById("question").innerHTML;
> >
> > While you are using a getElementById, which returns an ID, but adding  
> > .innerHTML will return the class value.
> >
> > Try it.
> >
> > Cheers,
> >
> > tedd
> 
> No, this will not work, if it appeared working, please re-check your data,  
> and make sure you didn't miss anything...
> 
> Run the following in any browser, and see whether you get a pop up, then  
> change class= to ID=, and run it again.
> <body onload='alert(document.getElementById("question").innerHTML)'>
> <p class="question">
>     Who is Roger Rabbit?
> </p>
> </body>
> 
> innerHTML works off an object, and it does nothing if youu cannot even  
> locate the object in the first place.
> 
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
> 


It might have worked in Internet Explorer, as for a while that browser
got confused over the class and id if two different elements on a page
had the same class and id values.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux