david wrote:
> Hi molo,
> 
> I think the innerHTML is the simpliest way to grab text inside a node.
> You could use prototype to do this, but treat your text node as a DOM
> node and use prototype traversal functions to get the node and verify
> its a text node. btw, not very interresting.
> 
> On the inconstency of innerHTML method across browser, I think there
> is only on the way browser treat "return" inside an HTML file as or
> not as a text node, but if any other inconsistency exist, ligth my
> mind :)
There's the textContent Property, too, which *is* inconsistent,
especially regarding that it is called innerText in IE.  I don't think
it's part of any standard at all.

I have sometimes used it like this:
  var text = elem.textContent || elem.innerText;

It has the advantage of filtering out all non-text stuff.  But that
doesn't seem to be needed in this special case, so it's probably
worthless for you.

Just thought I'd mention it.

Have fun
----Daniel



> On 24 août, 17:58, "Alex McAuley" <[email protected]>
> wrote:
>> Sorry been a long day - i didnt read the message properly!
>> Alex Mcauleyhttp://www.thevacancymarket.com
>>
>> ----- Original Message -----
>> From: "Andy Daykin" <[email protected]>
>> To: <[email protected]>
>> Sent: Monday, August 24, 2009 4:46 PM
>> Subject: [Proto-Scripty] Re: to InnerHTML or not to innerHTML?
>>
>>> I think he's asking how to get the innerHTML, not to set it. I actually
>>> ran
>>> into this problem a few days ago and decided to use innerHTML, but I was
>>> wondering too if there was a "prototype way" to do it. I have also heard
>>> that innerHTML is not consistent across browsers.
>>> --------------------------------------------------
>>> From: "Alex McAuley" <[email protected]>
>>> Sent: Monday, August 24, 2009 10:13 AM
>>> To: <[email protected]>
>>> Subject: [Proto-Scripty] Re: to InnerHTML or not to innerHTML?
>>>> Molo:
>>>> getValue will get the value of an element not its innerHTML.
>>>> http://www.prototypejs.org/api/element/update
>>>> i would use update();
>>>> $('someNode').update('<li>My lovely html</li>');
>>>> Alex Mcauley
>>>> http://www.thevacancymarket.com
>>>> ----- Original Message -----
>>>> From: "molo" <[email protected]>
>>>> To: "Prototype & script.aculo.us"
>>>> <[email protected]>
>>>> Sent: Monday, August 24, 2009 3:10 PM
>>>> Subject: [Proto-Scripty] to InnerHTML or not to innerHTML?
>>>>> Is there an alternative to innerHTML for getting the text in a td
>>>>> element (or any element) in the code below?
>>>>> I tried value and getValue but that did not work
>>>>> Is there any reason not to use innerHTML. I seem to remember reading
>>>>> that it is not a standardized way of doing things?
>>>>> ------------------------------------------------------------------------
>>>>> <thead id="headman" style="">
>>>>> <tr>
>>>>> <td class="TableHeader">Account</td>
>>>>> <td class="TableHeader">Shares</td>
>>>>> <td class="TableHeader">Restricted Shares</td>
>>>>> <td class="TableHeader">CostLocal</td>
>>>>> <td class="TableHeader">CostBase</td>
>>>>> <td class="TableHeader"/>
>>>>> </tr>
>>>>> </thead>
>>>>> ------------------------------------------------------------------------
>>>>> header = $('headman');
>>>>> headerTd = header.select('td.TableHeader');
>>>>>     headerTd.each(function(e){
>>>>>     cell = e.innerHTML;
>>>>>       row = row + cell + "\t";
>>>>>     });
> > 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to