简体   繁体   中英

How can I get a Codemirror tokens parent form?

How can I get the parent form from a codemirror token?

I've tried this but it does not work because nodeName is undefined.

var form = cm.parentNode;
while (form.nodeName != "FORM" && form.parentNode)
    form = form.parentNode;
alert(form.id);

If I can get the token's textarea, then the above code would work.

I managed to get the parent form without using the codemirror token.

var form = event.currentTarget;
while (form.nodeName != "FORM" && form.parentNode)
    form = form.parentNode;
alert(form.getAttribute("id"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM