Как мне назначить эту вновь созданную ссылку локальной переменной?
tblOutput += '<td>';
tblOutput += $('<a></a>')
.click(function (e) {
$.fancybox({ 'autoDimension': true, 'showCloseButton': true, 'type': 'iframe', 'href': 'WordManagerForm.aspx?cmd=updateword&categoryNodeID=' + nodeID + '&nodeID=' + id_text });
e.preventDefault();
})
.css('color', 'Blue')
.text(name_text);
tblOutput += '</td>';
Я пытался применить .html()
после .text(name_text)
, но выводит только текст, а не активную ссылку.Как я могу получить ссылку на работу?После того, как я прошел через цикл, я добавляю переменную tblOutput к div, используя $('#divOut').html(tblOutput);
Это сработало, когда я присвоил его элементу с идентификатором, например <div id="test"...>
, а затем .text(name_text).appendTo('#test');
.
Полный цикл:
$(xml).find('word').each(function () {
var id_text = $(this).attr('id');
var name_text = $(this).attr('name');
var translation_text = $(this).attr('translation');
$('<a></a>')
.click(function (e) {
$.fancybox({ 'autoDimension': true, 'showCloseButton': true, 'type': 'iframe', 'href': 'WordManagerForm.aspx?cmd=updateword&categoryNodeID=' + nodeID + '&nodeID=' + id_text });
e.preventDefault();
})
.css('color', 'Blue')
.text(name_text)
.appendTo('#bottomRight');
$('<br>').appendTo('#bottomRight');
});