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.

Troy III commented: An original working solution has already been handed to you - you need to say THANK YOU and mark your thread as "Solved" -2

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'
Member Avatar for stbuchok

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

@stbuchok because the elementname is actually a regular expression.

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;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.