亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery,js簡(jiǎn)單實(shí)現(xiàn)類似Angular.js雙向綁定

 更新時(shí)間:2017年01月13日 08:53:54   作者:carry~MF  
本文主要介紹了jquery,js簡(jiǎn)單實(shí)現(xiàn)類似Angular.js雙向綁定的方法。具有一定的參考價(jià)值,下面跟著小編一起來(lái)看下吧

剛了解了下Angular.js,發(fā)現(xiàn)Angular.js綁定數(shù)據(jù)方面非常方便,套下教程demo:

<div ng-app="myApp" ng-controller="myCtrl">
  名字: <input ng-model="name">
 <h1>你輸入了: {{name}}</h1>
</div>

我就想著,使用jq/js怎么實(shí)現(xiàn)類似的效果,后來(lái)找找,發(fā)現(xiàn)使用propertychange可以實(shí)現(xiàn)。

JQ:

<div class="wrap">
    <textarea></textarea>
    <div class="miss"></div>
 </div>
 $('textarea').on('input propertychange', function() {
   $('.miss').html($(this).val().length + "~"+$(this).val());
 });

JS:

var txt = document.querySelector("textarea"),
    msg = document.querySelector(".miss");
  //不兼容IE8 以下
  txt.addEventListener("input",function () {
    msg.innerHTML = this.value + "~"+this.value.length;
  },false)

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論