I’d like to get the text from between the “p” tags and put it in the title value.
before:
<option title="" value="Put Text">Put Text</option>
after:
<option title="$1,179.83" value="Put Text">Put Text</option>
Anyone know a javascript that can accomplish this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Get text and put in attribute value</title>
</head>
<body>
<div class="Text">
<p>$1,179.83</p>
</div>
<form action="">
<fieldset>
<select class="putText" name="put-Text">
<option title="" value="Put Text">Put Text</option>
</select>
</fieldset>
</form>
</body>
</html>
****************************** UPDATE 2011-09-13 ******************************
Code is working now. The code also works for ie6-8:
Should work in all browsers from IE4+ and NS7+
For newer browsers the document.getElementsByClassName is built in
DEMO HERE
Extra code for older browsers
}