我想通過將文本轉換爲文本字段來編輯文本。我只是想嘗試在我的瀏覽器,所以我複製並粘貼在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