1
$(document).ready(function () {
$('#cont6').hide();
$('#cont5').hide();
$('#cont4').hide();
$('#cont3').hide();
$('#cont2').hide();
$('#cont1_a').click(function () {
    $('#cont1').hide();
    $('#cont2').fadeIn(1000, function () {
        if ($.browser.msie && parseInt($.browser.version) == 7) {
            this.style.removeAttribute('filter');
        }
    });
    return false;
}); });

I have got another hyper link which needs to do the same function as above when clicked how can i integrate both the click function in it so that i don't need to duplicate the code, should i use AND operator for it , any suggestion will be highly appreciated

1 Answer 1

3

Either add a class to them both and bind that way, or do this:

$('#cont1_a, #cont1_b').click(...);

You could also move the function out of the handler definition and give it a name, then bind this way:

$("#cont1_a").click(functionName);
$("#cont1_b").click(functionName);

function functionName() {
     // function logic
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.