-1

Hi I am migrating code from javascript to jquery.
What would be the equivalent jquery of the following javascript.

document.getElementById("#elementname").getElementsByTagName('tagname');

Cheers.

Votes + Comments
An original working solution has already been handed to you - you need to say THANK YOU and mark your thread as "Solved"
5
Contributors
5
Replies
37
Views
4 Years
Discussion Span
Last Post by Troy III
0

Here are some examples using jQuery selectors...

$('p')    // Selects all paragraph elements
$('#one')   // Selects element with an ID = 'one'
$('.nav')   // Selects elements with a class = 'nav'

Edited by JorgeM

0

Just out of curiosity, why do yoiu even have document.getElementById("#elementname").getElementsByTagName('tagname');, ids are supposed to be unique on the page, there is no need for the getElementsByTagName

0

you could include my underdot lib

_ = document.getElementsByTagName("*")||document.all;

and use it like:

_[yourRegExp(returnedId)].getElementsByTagName(tag);

(instead of re-coding your project to accomodate jquery syntax)
its common syntax is: _.Id;

Edited by Troy III

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.