get value of an item using jquery -


i have situation have td:

<td id="divintimestamp-5-2" style="background: none repeat scroll 0% 0% red;">     12:55 pm      <span><img style="vertical-align: middle;" src="/content/themes/base/images/info.png"><span class="tooltip">clocked in from: <br>host: id14011.o2.local<br>ip address: 10.0.2.49</span></span>      <a title="edit clockin time" class="inline updatelink timesheetidentity" href="">[ Δ ]</a> </td> 

how can value 12:55 pm td?

var text = $.trim($('#divintimestamp-5-2')[0].firstchild.nodevalue); 

demo

  • [0] gets reference dom element #divintimestamp-5-2. shorthand .get(0).
  • .firstchild gets first child text node.
  • .nodevalue contains text node's content.
  • $.trim cross-browser white space trimming.

Comments