This would work to extract the number from the inner HTML of that '':
/[0-9.]+/
the other part of the problem is getting the HTML with the price in it. Here is a more complete example:
<html>
<head>
<script>
function toggle(e,id) {
val = parseFloat(e.innerHTML.match(/[0-9.]+/));
// Another method:
// val = parseFloat(e.innerHTML.match(/\$([0-9.]+)/)[1]);
alert(val);
}
</script>
</head>
<body>
<table border=1><tr>
<td headers="fee" style="cursor:pointer;" onclick="toggle(this,'detailinfo088180');">
$675.04
</td>
blabla<br><em>$650</em>">blabla/a>
</td>
</tr>
</table>
</body>
</html>
Note the following:
- The
toggle()
function takes an extra parameter, which is the element that was actually clicked. (Assuming you want the price to be extracted from the clicked element)
- I have provided another regular expression that is more restrictive (must have a "$" at the front of the number) in case this is what you need. The expression makes use of capturing ("
(..)
") to match a string and extract a portion of the string instead of the entire string.
If you want to know more about how regular expressions work, try here. Or Google.