■仕様
name=”○○○”の○○○の部分を抜き出す仕様
■ソース
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無題ドキュメント</title> <script type="text/javascript"> window.onload = function(){ document.getElementById('extract').onclick = function(){ var data = document.getElementById('data').value; var tmpAry = data.split('name="'); tmpAry.shift(); for(var i = 0, n = tmpAry.length; i < n; i++){ tmpAry[i] = tmpAry[i].substring(0, tmpAry[i].indexOf('"')); } var data = tmpAry.join(''); document.getElementById("data").value = data; } } </script> </head> <body> <form action="#"> <textarea name="data" id="data" cols="70″ rows="20″></textarea> <input type="button" name="extract" id="extract" value="extract" /> </form> </body> </html>
■あとがき
自宅のPCのデスクトップを整理したいんでブログにのっけました。。。ダブルクォーテーションでくくられた属性に対応してます。