我已使用以下方法将文本区域附加到元素:
$('#first').after('<textarea name="textarea" id="textarea" cols="45" rows="5"></textarea><button></button>');
我想在该文本区域调用 wysiwyg()
函数:
$('#textarea').wysiwyg();
这不起作用,因为该元素是附加在后面的。
有什么建议如何获取附加了 id #textarea 的元素以便在其上调用该函数吗?
最佳答案
试试这个:
$(parent_element_of_textarea).on('noevent', '#textarea' ,function(){
$(this).wysiwyg();
});
$('<textarea name="textarea" id="textarea" cols="45" rows="5"></textarea><button></button>').insertBefore('#first');
关于javascript - 访问 after() 附加的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25105950/