我想通过将文本转换为文本字段来编辑文本。我只是想尝试在我的浏览器,所以我复制并粘贴在Dreamweaver中,但它不工作:JavaScript代码不起作用
,你可以在这里找到:http://jsfiddle.net/cnuDh/
,但它不工作
的代码如下
<label id="edit" style="cursor:pointer; color:blue;">
edit
</label>
<table>
<tr>
<td>First Name:</td>
<td>John</td>
</tr>
<tr>
<td>Last Name:</td>
<td>Wright</td>
</tr>
</table>
<script type="text/javascript" charset="utf-8">
$('#edit').click(function() {
var $table = $('table');
if ($table.find('input').length) return;
$table.find('td:nth-child(2)').html(function (i, v) {
return '<input value=' + v + '>';
})
})
$('table').on('blur', 'input', function() {
$('table input').replaceWith(function() {
return this.value;
})
})
</script>
任何帮助,请
即使我有麻烦语法..如果你使用Firefox,你可以使用一个名为“萤火虫”,当他们出现错误,会告诉你的JavaScript错误的工具安慰。 – Silvertiger 2013-04-21 09:35:15
你把jquery添加到你的页面了吗? – 2013-04-21 09:37:24
请提一下你面对的错误 – 2013-04-21 09:47:48