pyquery icon indicating copy to clipboard operation
pyquery copied to clipboard

Different result about ":last" comparing jquery

Open kiddx01 opened this issue 8 years ago • 1 comments

html code here:

<!DOCTYPE html>
<html>
<head>
    <style>.highlight {
        background-color: yellow
    }</style>
    <script type="text/javascript" src="/jquery/jquery.js"></script>
</head>

<body>
    <p>
        <span>Look:</span>
        <span>This is some text in a paragraph.</span>
        <span>This is a note about it.</span>
    </p>
    <p>
        <span>Look:</span>
        <span>This is some text in a paragraph.</span>
        <span>This is a note about it.</span>
    </p>
    <p>
        <span>Look:</span>
        <span>This is some text in a paragraph.</span>
        <span>This is a note about it.</span>
    </p>
</body>
</html>

jquery

code

<script>$("p span:last").addClass('highlight');</script>

result: This is a note about it.

code:

<script>$("span:last").addClass('highlight');</script>

a same rsult This is a note about it.

pyquery

code:

html("p span:last").text()
#  'This is a note about it. This is a note about it. This is a note about it.'

html("span:last").text()
#  'This is a note about it.'

why the behavior of pyquery is different with jquery ? pyquery version: 1.2.17

kiddx01 avatar Apr 23 '17 02:04 kiddx01

because pyquery is not jQuery. It's hard to get the exact same behavior. Feel free to try to fix this one... :)

gawel avatar Oct 21 '17 10:10 gawel