简体   繁体   中英

How can i access variable inside jquery function globally anywhere in javascript?

const levelButtons = document.querySelectorAll('input[name="level"]');
Array.prototype.forEach.call(levelButtons, function(btn) {
  btn.addEventListener('change', function(){
   var selectedLevel = this.value;
  });
});
console.log(selectedLevel);

I want to use selectedLevel variable as a parameter (in place of 5000) in angularjs.

<tr ng-repeat="user in users | filter : searchtxt | filter: greaterThan('Fees', 5000)">
<td class="Program_Name">{{user.Program_Name}}</td>
<td class="Institute">{{user.Institute}}</td>
<td class="Fees">{{user.Fees}}</td>

You should define a global variable or instead you can create a function that return selectedLevel and use this return in your ng-repeat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM