Jq and js are simple to implement Angular. js two-way binding, jqangular. js

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.