开发者_StackOverflow社区This is my code :
<script>
function showVehical(type){
var element = document.getElementById('TotalCoach');
element.onblur="myfunction(type);";
}
function myfunction(type){
alert(type);
}
</script>
<HTML>
<body>
<input type="text" name="totalNumberOfCoach" id="TotalCoach" value="1"/>
</body>
</HTML>
The above code is working fine on opera but not in mozilla onblur() not working.
Try using a javascript library (like jQuery), to eliminate discrepancies between browsers.
Where do you call showVehical()? It needs to be after the TotalCoach input field is ready. This code works for me:
<script>
function showVehical(type){
var element = document.getElementById('TotalCoach');
element.onblur=function() {myfunction(type);};
}
function myfunction(type){
alert(type);
}
</script>
<HTML>
<body>
<input type="text" name="totalNumberOfCoach" id="TotalCoach" value="1"/>
<script>
showVehical("a");
</script>
</body>
</HTML>
精彩评论