문제

My list is something like this
<div id="jqxTree">
    <ul>
        <li>Parent1
            <ul>
                child1
            </ul>
        </li>
        <li>Parent2
            <ul>
                child2
            </ul>
            <ul>
                child2.1
            </ul>
        </li>
    </ul>
</div>

when i use jquery draggable its dragging entire list.How to i drag only child1,child2,child2.1 elements .To generalise i wanna drag only li elements inside ul which is inside li..

I tried using the below function but on mouseover the elements of li the elemnts get hidden

$('#jqxTree').delegate('li li', 'mouseover', function () {
    $(this).draggable({
        revert: true,
        revertDuration: 0
    });
}); 
도움이 되었습니까?

해결책

According to jQuery API page:

As of jQuery 1.7, .delegate() has been superseded by the .on() method.

Fiddle Demo

jQuery:

$(function () {
    $('#jqxTree').on('mouseenter mouseover', 'li > ul', function () {
        $(this).draggable({
            revert: true,
            revertDuration: 0
        });

    });
});

In CSS, use > between parent and child elements.

Also you had li li instead of li ul.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top