HighDots Forums  

ricavare childNodes cliccato in tabella

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss ricavare childNodes cliccato in tabella in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MidiQuiz
 
Posts: n/a

Default ricavare childNodes cliccato in tabella - 12-07-2007 , 04:00 PM






Ho una tabella con all'interno di ogni cella un link.
Come faccio sapere, quando clicco un link, in quale cella mi trovo.

Mi serve ricavare il link cliccato nella cella forma:
document.getElementById("Dest").childNodes.item(0) .childNodes.item
(0).childNodes.item(2).childNodes.item(0)
Come ricavo le coordinate della cella cliccata?

--
http://interno.altervista.org
http://midiquiz.altervista.org


Reply With Quote
  #2  
Old   
ZER0
 
Posts: n/a

Default Re: ricavare childNodes cliccato in tabella - 12-08-2007 , 04:49 AM






MidiQuiz <20825invalid (AT) mynewsgate (DOT) net> wrote:

Quote:
Ho una tabella con all'interno di ogni cella un link.
Come faccio sapere, quando clicco un link, in quale cella mi trovo.
Recuperi l'elemento che ha scatenato l'evento (tramite oggetto event o
tramite this, dipende come hai associato l'event-handler). Se tale
link è all'interno della TD e non ha altri nodi padri ti basta usare
la proprietà parentNode. Qualcosa del tipo:

<td>
<a href="#" onclick="f(this)">click me</a>
</td>

function f(sender){
sender.parentNode.backgroundColor="red";
}

Non sapendo come hai associato l'event-handler, questo era il metodo
più veloce per mostrarti l'approccio.
Ma come ti ho detto, tutto dipende dalla suddetta associazione.

--
"Se c'è qualcosa di più importante del mio ego su questa nave,
la voglio catturata e fucilata."


Reply With Quote
  #3  
Old   
MidiQuiz
 
Posts: n/a

Default Re: ricavare childNodes cliccato in tabella - 12-08-2007 , 05:04 AM



Ti ringrazio,
ad occhio sembra essere ciò di cui ho bisogno, lo proverò.
Ciao.

--
http://interno.altervista.org
http://midiquiz.altervista.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.