I have two pieces of jquery code, they work perfectly separate, but together – no.
Basicaly, there is code that generates textareas (with different id’s), and code that allows text in textareas to be formated. When text in textarea is bolded, it needs to stay like that, when i generate second textarea, and bold it, it need to stay bolded as well. Here it is:
<button id="bold">B</button>
<button id="add_txt">Add txtarea</button>
<div id="vk_main">
</div>
var c = 0;
$.activeEl = $();
$('#add_txt').on('click', function() {
var $div = $('<textarea id="ta_' + (c) + '">Text here.</textarea>');
$('#vk_main').append($div);
});
$("textarea").focus(function() {
$.activeEl = $(this);
});
$("#bold").click(function() {
$("textarea").css("font-weight", "");
$.activeEl.css("font-weight", "bold");
});
WORKING EXAMPLE: http://jsfiddle.net/JohnnyNT/qhjJs/
try this:
http://jsfiddle.net/qhjJs/5/