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).
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
Post a Comment