计数并获取ckeditor所选文本的锚定标记的属性
我想获得所选文本的锚定标记计数和html,例如从日期+到日期,其中从日期和到日期是锚定标记。资料来源如下:计数并获取ckeditor所选文本的锚定标记的属性,ckeditor,Ckeditor,我想获得所选文本的锚定标记计数和html,例如从日期+到日期,其中从日期和到日期是锚定标记。资料来源如下: <p> <a class="fic.fields" fieldognlexpression="${IUWP1_ICP_DT?string(datePattern)}" href=""> From Date </a> + <a class="fic.fields
<p>
<a class="fic.fields" fieldognlexpression="${IUWP1_ICP_DT?string(datePattern)}" href="">
From Date
</a>
+
<a class="fic.fields" fieldognlexpression="${IUWP1_EXP_DT?string(datePattern)}" href="">
To Date
</a>
</p>
当我选择From Date+To Date时,我想获得锚定标记的数量和锚定标记的fieldognlexpression属性,即。
${IUWP1_ICP_DT?stringdatePattern}+${IUWP1_EXP_DT?stringdatePattern}仅作为ckeditor中的输出假设您正在使用jQuery,下面介绍如何执行此操作
var anchors = $('a'); // get all anchors by simple 'a' selector
var anchorCount = anchors.length; // get anchors count
var expressions = []; // initialise empty expressions array
anchors.each(function(index){
// loop through all anchors and add their fieldognlexpression attribute value to the array
expressions[index] = $(this).attr('fieldognlexpression');
});
此处演示我想在ckeditor中使用它。我无法读取表达式中锚定标记的数量。我也无法从ckeditor的源部分获取表达式。不幸的是,您的要求非常不明确,请查看ckeditor文档,因为您可以通过javascript获取并设置textEditor内容。此外,根据您使用的CMS,包含的jQuery可能是不兼容模式,因此您需要将上述jQuery代码中的所有$symbol更改为jQuery,即var archors=jQuery'a';