1

I have

echo '<div><span>'.$wiersz['data'].'<i> added by: '.$wiersz['username'].'</i></span><span>Rate: </span><i **FROM HERE**>'.$wiersz['likes'].'</i><i>'.$wiersz['unlikes'].'</i></div>';

echo '<div><span>'.$wiersz['data'].'<i> added by: '.$wiersz['username'].'</i></span><span>Rate: <i>Thank you</i></span><i **OVERHERE**>'.$wiersz['likes'].'</i> <i>'.$wiersz['unlikes'].'</i></div>';

How Can I go FROM (FROM HERE) to the (OVER HERE) by selectors in jQuery? I'm hiding first div and showing second div. I need to increase innerText of OVERHERE but I dont know how to go there by selectors.

I did:

$(this).parent().next() 

this lead me to second div but still cant go into OVERHERE in second div.

10
  • 1
    That one line of jQuery is totally meaningless all by itself. We have no idea what you are looking for, what this is, or how this code gets run
    – charlietfl
    Jul 19, 2015 at 19:42
  • 3
    Show us the actual HTML code!. There is absolutely no reason to show us the PHP code that generates it. Jul 19, 2015 at 19:43
  • 1
    Come on. There is next to no PHP here
    – mplungjan
    Jul 19, 2015 at 19:44
  • Actual html is first line. This html is given dynamically.
    – xqz
    Jul 19, 2015 at 19:45
  • 2
    @xqz That is not the point. Your question is about jQuery. It has absolutely nothing to do with PHP. Since the PHP code generates the HTML, there is no reason for you to not show us the actual HTML code. Jul 19, 2015 at 19:55

2 Answers 2

2

try this..

$(this).parent().next().children()[2]
0
1

Assuming this is how the rendered HTML looks like

<div>
  <span>data<i> added by: username</i></span>
  <span>Rate: </span>
  <i onclick="$(this).closest('div').next().find('i').eq(2).text(parseInt($(this).text(),10))">25 Likes</i>
  <i>unlikes</i>
</div>
<div>
  <span>data<i> added by: username</i></span>
  <span>Rate: <i>Thank you</i></span><i>Will be overwritten </i> <i>unlikes</i>
</div>

Or $(this).parent().next() instead. However closest is safer in case you wrap your <i> in something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.