-1

I have added

$( "#target" ).toggle(function() {
    alert( "First handler for .toggle() called." );
    console.log("HIiiiiiiiiiii");
}, function() {
 alert( "Second handler for .toggle() called." );
 console.log("Helooooo");
});

In Html i have added.

<div class="calendarcell"><a href="" id="target" >'+ val.Title + '</a></div>

Can u please suggest Me

Theolodis
  • 4,727
  • 3
  • 32
  • 51
Abhishek
  • 43
  • 1
  • 1
  • 7

2 Answers2

0

as toggle for function is deprecated. You can use something like this:

 $( "#target" ).click(function() {
    var isclicked= $(this).data('isclicked');
     if(isclicked){
         funct1();
     }else{
         funct2();
     }
     $(this).data("isclicked", !isclicked);
 });

working demo

Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120
0

Try setting the data attribute for checking the event,

$('#target').live('click', function() {
    if ( $(this).data('flag') ) {
        console.log("HIiiiiiiiiiii");
    }else{
        console.log("Helooooo");   
    }

    $(this).data('flag', !$(this).data('flag'));
});
VPK
  • 2,994
  • 1
  • 26
  • 35