Jump to content

Get elements starting with ......


Recommended Posts

I have several ID's on my page.

 

Example:

<span id="Ship_1">stuff1</span>
<span id="Ship_2">stuff2</span>
<span id="Ship_3">stuff3</span>

 

I'm wanting to select all of the elements starting with Ship_ and work with them. The reason is, because the numbers will not always be predicable like it is above.

 

Maybe something like this (I'm using an SQL % to show an example of what I need)?

var ships = document.getElementById("Ship_%");
alert(ships[0].innerHTML);

 

Which would show stuff1

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/107929-get-elements-starting-with/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.