I am trying to unselect the other div i click on before. i have stored the old div id in an hidden input as you can see below i have added a alert so show the last div selected and it works fine but as soon as i try and change the div text color in css the whole script stops working.
function edit_addon(div_id) {
$("#"+div_id).attr('contentEditable', true);
$("#"+div_id).html()
$("#"+div_id).css('color','#F00');
$("#"+div_id).css('cursor','Text');
var old_div = $("input#selected_div").val();
alert(old_div);
$("#"+old_div).css('color','#000');
$("input#selected_div").val(div_id);
}
Are you sure the
alertworks fine? It should not work on the first pass because there was no value forselected_divuntil the first call toedit_addon.Modify the code to:
.
You can see it in action at jsfiddle. If you do, note that by changing the function to an event handler (as shown at jsfiddle) you can simplify the HTML and bind the function in a progressive-enhancement way.