I have a script for taking static text then being able to edit it on the fly by making it an input field. Works great except how can I make it for multiple fields?
Each time I change the text all of them change, which I understand because all are named the same class. Any help or suggestions are very helpful. Thanks.
Code:
$(document).ready(function() {
$("div.edit").click(function() {
if ($(this).children('input').length == 0) {
var inputbox = "<input type='text' class='inputbox' value=\""+$(this).text()+"\">";
$(this).html(inputbox);
$("input.inputbox").focus();
$("input.inputbox").blur(function() {
var value = $(this).val();
$(".edit").text(value);
});
}
});
});
Code:
<tr>
<td><div class="edit">Home</div></td>
<td> <a href=""><img src="_gfx/cross.png" /></a></td>
</tr>
<tr class="odd">
<td><div class="edit">Products</div></td>
<td> <a href=""><img src="_gfx/cross.png" /></a></td>
</tr>