treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] How to use "this" in jQuery?

  • Hi All,

    Just trying to figure out how to use the "this" selector in jQuery. I am looking for when one li item is clicked that word changes rather than all of them like they are doing right now. My code is below.

    Update:
    The solved code is on my CodePen page http://codepen.io/jbatzel1/pen/this/11

    <ul>
    <li class="bike1">Yeti Mountain Bikes</li>
    <li class="bike1">Gary Fisher Mountain Bikes</li>
    <li class="bike1">Iron Horse Mountain Bikes</li>
    </ul>

    <ul>
    <li class="bike2">GT Mountain Bikes</li>
    <li class="bike2">Trek Mountain Bikes</li>
    <li class="bike2">Specialized Mountain Bikes</li>
    </ul>


    $(".bike1").click(function(){
    $(this).html("Mountain Bikes");
    });
  • Figured it Out!
  • Thanks for your input. Please indicate the topic as solved. This will improve visibility in the list of forum items and we go to avoid resolving the issue, as when making a rhetorical question.