1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <html>
<head>
<style>
div{border:solid;};
</style>
<script>
var jlc = {SelectVal:function(){}};
jlc.addEvent = function (obj, evType, fn) {
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return false;
}
else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return false;
}
};
function Cc(){
this.pa = document.getElementById('pa');
this.pv = document.getElementById('pv');
this.cx = document.getElementById('cx');
this.mb = document.getElementById('mb');
this.tva = document.getElementById('tva');
this.tq = document.getElementById('tq');
this.init();
}
Cc.prototype.init = function(){
this.vtva = parseFloat(jlc.SelectVal('tva'));
this.vpa = parseFloat(this.pa.value)||false;
this.vpv = parseFloat(this.pv)||false;
this.vcx = parseFloat(this.cx)||false;
};
Cc.prototype.comportement = function(){
jlc.addEvent(this.tq,'click',this.test);
};
Cc.prototype.test = function(){
alert('Dedans la méthode');
};
window.onload = function(){
var c = new Cc();
c.comportement();
};
</script>
</head>
<body>
<div id=pa>pa</div>
<div id=pv>pv</div>
<div id=cx>cx</div>
<div id=mb>mb</div>
<div id=tva>tva</div>
<div id=tq>tq(cliquable)</div>
</body>
</html> |