使用jQuery选择焦点上的文本在firefox中不起作用
我有下面的jQuery代码,可以在Chrome中运行,但是没有失败,没有错误,只是在firefox中不起作用。当我试图用双击鼠标来选择文本框中的文本时,它没有选择文本,光标会移到文本的开头。有没有办法解决这个问题 我的jqueryandajax 我的html使用jQuery选择焦点上的文本在firefox中不起作用,jquery,ajax,firefox,browser,focus,Jquery,Ajax,Firefox,Browser,Focus,我有下面的jQuery代码,可以在Chrome中运行,但是没有失败,没有错误,只是在firefox中不起作用。当我试图用双击鼠标来选择文本框中的文本时,它没有选择文本,光标会移到文本的开头。有没有办法解决这个问题 我的jqueryandajax 我的html 请试试这个可能会有帮助 $('td.edit').click(function(e){ var $target = $(e.target); if($target.is('#editbox')){
请试试这个可能会有帮助
$('td.edit').click(function(e){
var $target = $(e.target);
if($target.is('#editbox')){
return;
}
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
$(this).addClass('ajax');
$(this).html('<input id="editbox" size="'+$(this).text().length+'" type="text" value="' + $(this).text() + '">');
$('#editbox ').focus();
}
);
请发布完整的html代码发布我的代码请指导如何修复this@jamie我试过了,但它不起作用。我从firefox中获取了这段代码。请在firefox中打开这段代码,并尝试打开最后一列,然后您了解问题所在。谢谢
<html>
<table id="sorting" class="tablesorter" style="width: 100px; table-layout: fixed;" >
<thead>
<tr>
<th>6xxA <span> <img id="logo" src="/image/Picture2.png" style="margin:-62px -21px -9px 17px"></span>
<th>6xxB <span> <img id="logo" src="/image/Picture2.png" style="margin:-62px -21px -9px 21px"></span>
</th>
<th >10xx <span> <img id="logo" src="/image/Picture2.png" style="margin:-62px -21px -9px 32px"></span>
</th>
<th >11xx <span> <img id="logo" src="/image/Picture2.png" style="margin:-62px -21px -9px 32px"></span>
</th>
<th >12xx <span> <img id="logo" src="/image/Picture2.png" style="margin:-62px -21px -9px 32px"></span>
</th>
<th >11xx <span> <img id="logo" src="/image/Picture2.png" style="margin:-62px -21px -9px 32px"></span>
</th>
</tr>
</thead>
<tbody >
<?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'fms';
$dbPassword = 'xxxxxxxx';
$dbDatabase = 'fms';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");
$sql = mysql_query("SELECT * FROM supplierprice");
while($rows=mysql_fetch_array($sql))
{
if($alt == 1)
{
echo '<tr class="alt">';
$alt = 0;
}
else
{
echo '<tr>';
$alt = 1;
}
echo ' <td class="edit region '.$rows["supp_price_id"].'">'.$rows["region"].'</td>
<td class="edit country '.$rows["supp_price_id"].'">'.$rows["country"].'</td>
<td class="edit networkname '.$rows["supp_price_id"].'">'.$rows["networkname"].'</td>
<td class="edit mcc '.$rows["supp_price_id"].'">'.$rows["mcc"].'</td>
<td class="edit mnc '.$rows["supp_price_id"].'">'.$rows["mnc"].'</td>
<td class="edit mnp '.$rows["supp_price_id"].'">'.$rows["mnp"].'</td>
</tr>';
}
?>
</tbody>
</table>
</body>
</html>
$('td.edit').click(function(e){
var $target = $(e.target);
if($target.is('#editbox')){
return;
}
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
$(this).addClass('ajax');
$(this).html('<input id="editbox" size="'+$(this).text().length+'" type="text" value="' + $(this).text() + '">');
$('#editbox ').focus();
}
);