html
<textarea onchange="reg_find(this.value)" ></textarea>
<div id="info"></div>
javascript
<script>
function reg_find(val){
var find_str = "a" ;
var reg = new RegExp(find_str,"g");
var result = val.match(reg);
var count = (result)?result.length:0;
document.getElementById("info").innerHTML = "數量有:" + count + "個" ;
}
</script>
範列:查詢文字框 a 的數量
沒有留言:
張貼留言