I am having a problem with a function I am trying to write. I can't change the CSS on the second list item because it's telling me that "css is not a function."
I am trying to make it so that when you hover over one of the list item points, it will show the copy related to that item in a separate box.
Here is a sample code:
HTML
- <ol class="poster-list" id="poster-list">
- <li class="pt-1">1</li>
- <li class="pt-2">2</li>
- <li class="pt-3">3</li>
- </ol>
- <ol class="pt-copy" id="pt-copy">
- <li class="pt-copy-1"><b>Treeless Parking Lots</b></li>
- <li class="pt-copy-2"><b>Treeless Streets</b></li>
- <li class="pt-copy-3"><b>Asphalt Playgrounds</b></li>
- </ol>
JavaScript/jQuery
- $(function(){
- $("#poster-list li").hover(function(){
- var ptX = $(".poster-list li").index($(this)); //Find the index of this list item.
- $(".pt-copy").css("display","block"); //Shows the containing UL
- var ptCopyX = $("#pt-copy li")[ptX]; //Uses index to find matching list item in second list.
- alert(ptCopyX); //Results in "[object HTMLLIElement]"; innerHTML shows the element matches.
- ptCopyX.css("display","block"); //Error: "ptCopyX.css is not a function."
- });
- });
I feel like the solution will be really obvious, but I'm stuck.