我希望获得所选文本的锚标记计数和html,例如。从日期+到日期,其中从日期和到日期是锚标记。他们的来源如下: -
<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?string(datePattern)} + ${IUWP1_EXP_DT?string(datePattern)}
仅作为ckeditor的输出
答案 0 :(得分:0)
假设您在这里使用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');
});