Skip to content Skip to sidebar Skip to footer

How To Retrieve All Td Where The Id Begin By Td_ In Javascript

I need your help :) ! I have a page where there are a lot of tags and I have to retrieve in an array all id who begin by td_ I can not use the jQuery framework... Else there will

Solution 1:

You can use the querySelector:

elementList = document.querySelectorAll('td[id^=td_]');

Solution 2:

DEMO

var nodeList = document.querySelectorAll('[id^=td_]'); // or if only TDs are tergated use: 'td[id^=td_]' instead   {thx Derek}var arr = []; // Will hold the array of Node'sfor (var i = 0, ll = nodeList.length; i < ll; arr.push(nodeList[i++]));

Post a Comment for "How To Retrieve All Td Where The Id Begin By Td_ In Javascript"