I need to use the 'on' function instead of the "hover". This is the old code:
$('.field').hover( function() { old_value=$(this).text(); item_id=$(this).attr('id'); item=$(this).parent('td'); new_value=(old_value=='Not translated') ? '' : old_value; $(this).empty(); var field="<div id='save_button' class='btn btn-primary' style='float: right' href='#'>Save</div><form>"+ "<div style='overflow: hidden; padding-right: .5em;'>"+ "<input id='new_value' type='textarea' name='term' style='width: 100%;' value='"+new_value+"'/></div></form>"; $(this).html(field); }, function() { $(this).empty(); $(this).html(old_value); });
And this is the new code:
$('.field').on('hover', function(event) { old_value=$(this).text(); item_id=$(this).attr('id'); item=$(this).parent('td'); new_value=(old_value=='Not translated') ? '' : old_value; $(this).empty(); var field="<div id='save_button' class='btn btn-primary' style='float: right' href='#'>Save</div><form>"+ "<div style='overflow: hidden; padding-right: .5em;'>"+ "<input id='new_value' type='textarea' name='term' style='width: 100%;' value='"+new_value+"'/></div></form>"; $(this).html(field); }, function(event) { $(this).empty(); $(this).html(old_value); });
The old code works well, but the new one does not work (only the mouseout function works). Please tell me where I made a mistake? Thanks.
source share