javascript - Passing Multiple Inner Child Node to Function -


i need pass contents of inside div function, example myfun(string). have tried using

myfun((this).children[0].innerhtml)

myfun((this).children[1].innerhtml)

myfun((this).children[0].children[0].innerhtml)

but none of seem work. can't pass getelementbyid value because function should generic since called php on various <a> elements (ideally think should include this. keyword).

enter image description here

thanks help.

in function, "this" refers link, , can't used.

a cleaner solution have myfunc know going receive object contains text

javascript:

myfunc(obj){    alert(obj.childnodes[0].nodevalue); } 

html

   <a href="#" onclick="myfunc(document.getelementbyid('target'));return false;">click</a>    <div id="target">target contents</div> 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -