Monday 15 August 2011

javascript - TypeError getElementsByTagName is not a function issue -



javascript - TypeError getElementsByTagName is not a function issue -

i'm having problem getting source of problem. error message getting in console is:

typeerror: $(...).getelementsbytagname not function

when click through line occuring on here:

var inputs = $('directoryresults').getelementsbytagname('input');

i'm not sure why happening have included jquery in header of page itself:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>

does have ideas might causing this?

does have ideas might causing this?

the object returned jquery constructor doesn't have .getelementsbytagname() method.

$('selector') returns jquery object. .getelementsbytagname() native javascript method of dom elements.

to elements tagname using jquery object have:

var inputs = $('directoryresults input'); // or var inputs = $('directoryresults').find('input');

to like-for-like node list .getelementsbytagname() homecoming (note isn't same, homecoming array .getelementsbytagname() homecoming htmlcollection):

var inputs = $('directoryresults input').get();

note: directoryresults, assuming, either class or id of dom element. either way you'll want amend selector above

javascript jquery

No comments:

Post a Comment