It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

javascript - 2 functions onclick

javascript - 2 functions onclick

Postby Altar on Wed Sep 28, 2011 11:40 pm

Hello,
I would like to launch 2 functions onlick, so I have tried 3 different ways, but it didint worked:
1. <div id="1" class="buttonas" onmouseover="button_on(1)" onmouseout="button_off(1)" onclick="text(1);textleft(1)">Apie įmonę</div>

At this case works only the first function text(1).

2.Tried using 1 function for calling those 2 and wrote that into the div:
function funkcija (num){
var i=num;
text(i);
textleft(i);
}

At this case works only the first function text(1)

3. Using jquery, tried to call functions in div id:
$('#1').click(function() {
text(1);
textleft(1);
});
$('#2').click(function() {
text(2);
textleft(2);
});

At this case none of the functions work.


Could you help me to solve this problem ?
Altar
 
Posts: 1
Joined: Wed Sep 28, 2011 11:05 pm

Re: javascript - 2 functions onclick

Postby mfsikrushnas on Tue Nov 01, 2011 11:33 am

Hi,
See if you want to call 3 different functions on any event,do one define only one function and call that function on any event then define those previously 3 function
inside the new one.
like:
<script type="text/javascript">
function 1(){//define here//}
function 2(){//define here//}
function 3(){//define here//}
function 4(){
1();2();3();}
</script>
<body>
<input type="submit" onclick="4();">
</body>

Thats it.
mfsikrushnas
 
Posts: 2
Joined: Mon Oct 31, 2011 12:01 pm


Who is online

Users browsing this forum: No registered users and 3 guests