Link to home
Start Free TrialLog in
Avatar of greddin
greddinFlag for United States of America

asked on

Help with Javascript innerHtml please

I have a Javascript that is looping through a table's rows.  One of table cells (TD) contains a date.   Here's a sample:

<td class="ms-cellstyle ms-vb2"><span class="ms-noWrap" title="10/30/2015">10/30/2015</span></td>

Open in new window


I have a variable named "col_date" which needs contain just the date (10/30/2015).

var col_date = row.cells[suspense_date_column].innerHTML;

Open in new window


Right now col_date contains the whole  
<span class="ms-noWrap" title="10/30/2015">10/30/2015</span>

Open in new window

.  How can I return just the date without the span tag?

Thanks
SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
+1 for Tom`s solution

Question: the HTML of the cell looks like a SharePoint generated table (at least the class names do :-))

Why dont you use jQuery?

Alternative solution:
var col_date = row.cells[suspense_date_column].getElementsByTagName('span')[0].getAttribute("title"); 

Open in new window


HTH
Rainer
Avatar of greddin

ASKER

Thanks, both solutions are perfect. Appreciate the help!