在子元素中查找匹配项/trumbowyg
find match in child elements / trumbowyg
我有一个表单,我必须使用 trumbowyg 检查 textarea/ div 中的元素。
$("#test").keyup(function() {
var val = $(this).val();
if (val.match(/{event_title}/g)) {
$("p.eventTagTitle").addClass("true");
} else {
$("p.eventTagTitle").removeClass("true");
}
if (val.match(/{event_form}/g)) {
$("p.eventTagForm").addClass("true");
} else {
$("p.eventTagForm").removeClass("true");
}
if (val.match(/{event_author}/g)) {
$("p.eventTagAuthor").addClass("true");
} else {
$("p.eventTagAuthor").removeClass("true");
}
});
但是
在 trumbowyg 中不起作用
将文本添加到 div
时,trumbowyg 中的类似解决方案不起作用
Trumbowyg 编辑器有特别活动:tbwchange
(来自 http://alex-d.github.io/Trumbowyg/documentation.html)。
你应该只替换一行
$("#test").keyup(function() {
到
$("#test").on('tbwchange', function() {
完成于 fiddle:http://jsfiddle.net/f1m33312/6/
我有一个表单,我必须使用 trumbowyg 检查 textarea/ div 中的元素。
$("#test").keyup(function() {
var val = $(this).val();
if (val.match(/{event_title}/g)) {
$("p.eventTagTitle").addClass("true");
} else {
$("p.eventTagTitle").removeClass("true");
}
if (val.match(/{event_form}/g)) {
$("p.eventTagForm").addClass("true");
} else {
$("p.eventTagForm").removeClass("true");
}
if (val.match(/{event_author}/g)) {
$("p.eventTagAuthor").addClass("true");
} else {
$("p.eventTagAuthor").removeClass("true");
}
});
但是
在 trumbowyg 中不起作用
将文本添加到 div
时,trumbowyg 中的类似解决方案不起作用Trumbowyg 编辑器有特别活动:tbwchange
(来自 http://alex-d.github.io/Trumbowyg/documentation.html)。
你应该只替换一行
$("#test").keyup(function() {
到
$("#test").on('tbwchange', function() {
完成于 fiddle:http://jsfiddle.net/f1m33312/6/