سؤال

This function selects a datatable row and gives the value of the row on a single click.

How is it possible to make this function work on dblclick like the evt on singleclick works?

Is there something like (evtdblclick)?

var oldRow = null; 
 x = null;
function marktesttable( evt ) 
    { 
        var selectedRow = ( evt.target || evt.srcElement ); 
        while ( selectedRow.tagName != "TR") 
            selectedRow = selectedRow.parentNode; 
        if ( oldRow )  
            {  
            oldRow.style.backgroundColor = "";
            oldRow.style.color ="";  
            if ( oldRow == selectedRow ) 
                { 
                oldRow = null;
                document.getElementById('iddemo1').value = null;
                x = null;
                return true;  
                } 
            };  
        selectedRow.style.backgroundColor = "#006bb6"; 
        selectedRow.style.color ="white";
        oldRow = selectedRow;
        x = selectedRow.textContent;
        document.getElementById('iddemo1').value = x;
        fillGespraechsnotiz(x);         
} 
هل كانت مفيدة؟

المحلول

Try to use .dblclick() event

The dblclick event occurs when an element is double-clicked.

The dblclick() method triggers the dblclick event, or attaches a function to run when a dblclick event occurs.

  $( "#target" ).dblclick(function(evt) {
    marktesttable(evt);
    });

http://api.jquery.com/dblclick/

Thanks,

Siva

نصائح أخرى

Use jquery double click function:

$('button').dblclick(function(){ marktesttable(); });

This should work, if not try click counter like this using single click function, hope this helps:

count=0; $('button').click(function() { count++; if(count==2) { marktesttable(); count=0; } });

$("#button").dblclick(function() {
   marktesttable(); 
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top