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.
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.
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'
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;
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.