0

Hi every one i am new to JQuery.i have a problem with click event.i am taken temearea_div as a container when ever rightclick passing an argument(classname) with that clearfunction is executed and copy Html content into tempaarea_div .i had a problem while click a class with specific index. click is not identifying.could any one solve my problem. how to give selector to identify click with specific index.thanks in advance

THis is My Html Code

 <div class="temparea_div"> 
 <img src="img/Img_01.png"/>
 </div>
    <div class="Maintain_submenu_nav_02" style="display: none;">
    <div class="maintainence_image_02"></div>
    <div class="maintainence_image_02" style=" left: 22.2%;top: 32.7%;"></div>
    <div class="maintainence_image_02" style="top: 35.7%;top:42.7%"></div>
    <div class="maintainence_image_02" style="top: 35.7%;top:53.7%"></div>
    <img src="img/Img_02.png"/>    
 </div>

My JQuery Code

$('.rightclick').bind(function(){

    clearfunction('Maintain_submenu_nav_02');
});   

var clearfunction=function(e){
    $(".temparea_div").empty();
     $('.'+e).show();
      $(".temparea_div").html($('.'+e).html());
      $('.'+e).hide();

};

this is not identidentiding click

$('.maintainence_image_02:eq(1)').bind('click', function() {
            $('.maintainence_image_02:eq(1)').css("border", "1px solid #00FFFF");
            maintaincesubmenu = true;
        });

i used this one but when click temparea_div then .maintainence_image_02:eq(1) calling

 $('.temparea_div').bind('click','.maintainence_image_02:eq(1)', function() {
        $('.maintainence_image_02:eq(1)').css("border", "1px solid #00FFFF");
        maintaincesubmenu = true;
    });

2 Answers2

1

Try:

$('.temparea_div').on('click','.maintainence_image_02:eq(1)', function() {
    $('.maintainence_image_02:eq(1)').css("border", "1px solid #00FFFF");
    maintaincesubmenu = true;
});
Ramesh
  • 4,223
  • 2
  • 16
  • 24
  • hay this working .. but tell me what is difference between bind and on .i think on event is for jQuery1.8 after. how do i get for previous versions. – Sarath Babu Nuthimadugu Nov 13 '13 at 06:24
  • See here: http://stackoverflow.com/questions/8065305/whats-the-difference-between-on-and-live-or-bind – Ramesh Nov 13 '13 at 06:30
  • 1
    The idea for adding .on() was to create a unified event API, rather than having multiple functions for binding event; – Sridhar R Nov 13 '13 at 06:31
0

If rightclick is class then :

$('.rightclick').bind(function(){

    clearfunction('Maintain_submenu_nav_02');
});  
Ankit Tyagi
  • 2,381
  • 10
  • 19