Я назначаю значение для события keyup в свойстве объекта javascript. Он печатает нуль в консоли.Ошибка Null в javascript
function check(id){
var me= this;
this.ID= null;
this.matchName= this.ID.substr(this.ID.lastIndexOf('_'));
this.first= function(){
alert(me.matchName)
}
this.second= function(){
alert(1)
}
this.touch= function(){
$(id).find('input').keyup(function(e){
me.ID= this.id;;
if(e.keyCode==13){
id.indexOf('first')>-1? me.first(): me.second();
}
})}
}
тела
<div class="first">
<input type="text" id="val_00_01" />
</div>
<div class="two">
<input type="text" id="val_00_02"/>
</div>
<script type="text/javascript">
var first= new check('.first');
var two= new check('.two');
first.touch()
two.touch()
</script>
Вы забыли задать вопрос и форматировать свой код. – MightyPork
Вы не привели нам пример того, где код разбивается или в каком сценарии, когда он работает. – NoLifeKing