0

I'm having issues with identifying the parent of one of my child nodes . code is as follows

if (!queryCommandState('InsertUnorderedList') 
    && !queryCommandState('InsertOrderedList')) {
    // If forced_root_blocks is set to false we don't have a block to indent so lets create a div
    if (!settings.forced_root_block 
        && !dom.getParent(selection.getNode(), dom.isBlock)) {
        formatter.apply('div');
    }

    each(selection.getSelectedBlocks(), function(element) {
        var indentStyleName;

        if (element.nodeName != "LI") {
            indentStyleName = dom.getStyle(element, 'direction', true) == 'rtl' ? 'paddingRight' : 'paddingLeft';

            if (command == 'outdent') {
                value = Math.max(0, parseInt(element.style[indentStyleName] || 0, 10) - intentValue);
                dom.setStyle(element, indentStyleName, value ? value + indentUnit : '');
            } else {
                value = (parseInt(element.style[indentStyleName] || 0, 10) + intentValue) + indentUnit;
                dom.setStyle(element, indentStyleName, value);
            }
        }
        if (element.nodeName=== "OL"){
            alert ("got");
        } else {
            alert (element.nodeName);
        }
    });
}
  • want to find the parent of the "element.nodeName"*
4

2 に答える 2

1

element.parentNodeを使用して、親ノードを取得できますelement

于 2013-06-26T03:57:34.193 に答える
1

jquery.parent()または使用できますjquery.closest()

お気に入り、

$(element).parent('selecter');

また

$(element).closest('selecter');

また

$(element).parents('selecter');

ドキュメントの親() 最も近い() 親()

于 2013-06-26T04:23:14.460 に答える