如何更改此代码以在onchange时调用函数?

时间:2016-12-27 06:33:27

标签: javascript jquery

如何更改此代码以在onchange时调用函数?

<body>
<p><textarea autofocus="">i ♥ u</textarea>
</p><p>That’s <strong id="characters"></strong>, totaling <strong id="bytes"></strong>.
</p>
<script src="//www.google-analytics.com/ga.js"></script><script>/*! http://mths.be/utf8js v2.0.0 by @mathias */
;(function(n){var g=typeof exports=="object"&&exports;var t=typeof module=="object"&&module&&module.exports==g&&module;var m=typeof global=="object"&&global;if(m.global===m||m.window===m){n=m}var l=String.fromCharCode;function f(x){var w=[];var v=0;var y=x.length;var z;var u;while(v<y){z=x.charCodeAt(v++);if(z>=55296&&z<=56319&&v<y){u=x.charCodeAt(v++);if((u&64512)==56320){w.push(((z&1023)<<10)+(u&1023)+65536)}else{w.push(z);v--}}else{w.push(z)}}return w}function q(y){var w=y.length;var v=-1;var x;var u="";while(++v<w){x=y[v];if(x>65535){x-=65536;u+=l(x>>>10&1023|55296);x=56320|x&1023}u+=l(x)}return u}function e(v,u){return l(((v>>u)&63)|128)}function p(u){if((u&4294967168)==0){return l(u)}var v="";if((u&4294965248)==0){v=l(((u>>6)&31)|192)}else{if((u&4294901760)==0){v=l(((u>>12)&15)|224);v+=e(u,6)}else{if((u&4292870144)==0){v=l(((u>>18)&7)|240);v+=e(u,12);v+=e(u,6)}}}v+=l((u&63)|128);return v}function o(x){var w=f(x);var y=w.length;var v=-1;var u;var z="";while(++v<y){u=w[v];z+=p(u)}return z}function a(){if(j>=i){throw Error("Invalid byte index")}var u=k[j]&255;j++;if((u&192)==128){return u&63}throw Error("Invalid continuation byte")}function c(){var v;var u;var y;var x;var w;if(j>i){throw Error("Invalid byte index")}if(j==i){return false}v=k[j]&255;j++;if((v&128)==0){return v}if((v&224)==192){var u=a();w=((v&31)<<6)|u;if(w>=128){return w}else{throw Error("Invalid continuation byte")}}if((v&240)==224){u=a();y=a();w=((v&15)<<12)|(u<<6)|y;if(w>=2048){return w}else{throw Error("Invalid continuation byte")}}if((v&248)==240){u=a();y=a();x=a();w=((v&15)<<18)|(u<<12)|(y<<6)|x;if(w>=65536&&w<=1114111){return w}}throw Error("Invalid UTF-8 detected")}var k;var i;var j;function b(w){k=f(w);i=k.length;j=0;var u=[];var v;while((v=c())!==false){u.push(v)}return q(u)}var d={version:"2.0.0",encode:o,decode:b};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define(function(){return d})}else{if(g&&!g.nodeType){if(t){t.exports=d}else{var r={};var h=r.hasOwnProperty;for(var s in d){h.call(d,s)&&(g[s]=d[s])}}}else{n.utf8=d}}}(this));(function(g,h){var j=h.getElementsByTagName("textarea")[0],b=h.getElementById("characters"),l=h.getElementById("bytes"),k=h.getElementById("permalink"),i=/(?=(?:\d{3})+$)(?!\b)/g,f=(function(){var n=new Date,p,m;try{(p=g.localStorage).setItem(n,n);m=p.getItem(n)==n;p.removeItem(n);return m&&p}catch(o){}}());function d(p){var o=[],n=0,q=p.length,r,m;while(n<q){r=p.charCodeAt(n++);if(r>=55296&&r<=56319&&n<q){m=p.charCodeAt(n++);if((m&64512)==56320){o.push(((r&1023)<<10)+(m&1023)+65536)}else{o.push(r);n--}}else{o.push(r)}}return o}function e(m){return encodeURIComponent(m).replace(/['()_*]/g,function(n){return"%"+n.charCodeAt().toString(16)})}function a(n,m){return String(n).replace(i,",")+" "+m+(n==1?"":"s")}function c(){var o=j.value.replace(/\r\n/g,"\n"),n=e(o),p=utf8.encode(o).length,m=d(o).length;b.innerHTML=a(m,"character");l.innerHTML=a(p,"byte");k.hash=n;f&&(f.byteCountText=o)}j.onkeyup=c;j.oninput=function(){j.onkeyup=null;c()};if(f){f.byteCountText&&(j.value=f.byteCountText);c()}g.onhashchange=function(){j.value=decodeURIComponent(location.hash.slice(1));c()};if(location.hash){g.onhashchange()}}(this,document));window._gaq=[["_setAccount","UA-6065217-60"],["_trackPageview"]];(function(e,a){var c=e.createElement(a),b=e.getElementsByTagName(a)[0];c.src="//www.google-analytics.com/ga.js";b.parentNode.insertBefore(c,b)}(document,"script"))</script>
</body>

通常,此代码将调用函数onkeypress然后我想更改为onchange,我该怎么做?

0 个答案:

没有答案