Jq and js are simple to implement Angular. js two-way binding, jqangular. js
I just learned about Angular. js and found that it is very convenient for Angular. js to bind data. Set the tutorial demo below:
1 <div ng-app = "myApp" ng-controller = "myCtrl"> 2 name: <input ng-model = "name"> 3 View Code
I thought about how to implement similar effects using jq/js. Later, I found that propertychange can be used.
JQ:
1 <div class = "wrap"> 2 <textarea> </textarea> 3 <div class = "miss"> </div> 4 </div>
View Code
1 $ ('textea '). on ('input propertychange', function () {2 values ('.miss'{.html ($ (this). val (). length + "~ "+ $ (This). val (); 3 });View Code
JS:
1 var txt = document. querySelector ("textarea"), 2 msg = document. querySelector (". miss "); 3 // not compatible with 4 txt files under IE8. addEventListener ("input", function () {5 msg. innerHTML = this. value + "~ "+ This. value. length; 6}, false)View Code