I am trying to pass a data from one click function to another and have no idea how to make it. I have multiple divs but i will show you the main idea on two divs:
<div class="classname" id='prev'></div>
<div class="classname" id='next'></div>
$('#next).click(function() {
$('.classname').trigger('click')
})
$('#prev).click(function() {
$('.classname').trigger('click')
})
$('.classname').live('click', function () {
[a lot of code here depending on who called click]
})
now, i would like to pass a variable like that (or somehow familiar
$('#prev').click(function() {
a = 1;
$('.classname').trigger('click', a)
})
$('.classname').live('click', function (a) {
if ( a == 1 ) { do something } else { do something else }
[a lot of code here depending on who called click]
})
How can i send 'a' variable to live click to let it baheva differently depending on value of 'a' variable?
I think you're looking for this (see DEMO):
$('#prev').click(function () {
$('.classname').trigger('click', [1])
});
$('.classname').live('click', function (event, param) {
if (param == 1) {
alert('do something');
} else {
alert('do something else');
}
})