1

以下のように CKeditor Element1 の外側の html:

<element1 id="s1">
<mytag>Test1</mytag>
<span> </span>
Some text
<mytag>Test</mytag>
<span> </span>
<mytag>Test3</mytag>
some text
<span> </span>
</element>

var element1=EditorIns.document.getById("s1");
EditorIns.focus();
var mt=element1.getElementsByTag("mytag");
alert(mt.count());

通常は問題なく動作していますが、mt.count()0 になることもあります。

次のようなjQueryでも試しました:

$(element1.$).find("mytag").length;

これにも同じ問題があります。この問題から私を助けてください

4

2 に答える 2

1
Write the code in a function And call this function same as following :-

<script type="text/javascript">
function testElement(){
var element1=EditorIns.document.getById("s1");
EditorIns.focus();
var mt=element1.getElementsByTag("mytag");
alert(mt.count());
}


window.onload=testElement;

</script>

The element is loading after complete the page load and window.onload will call when all the elements completely loaded on the page.
于 2014-03-03T12:20:35.510 に答える