What I want to do is something like this:
$(".chat-wrapper").on("click", ".chat-wrapper li", function(){
$(this.name).hide();
});
the structure would be:
<ul class="chat-wrapper">
<li><img src=""/><a class="name">Name 1</a><div class="body"></div></li>
<li><img src=""/><a class="name">Name 2</a><div class="body"></div></li>
</ul>
so when you click on Name 2 it would hide that name class only. (my li element has more than 1 class inside, i want to be able to select which one I want)
(This is not the actual reason I need to do this, but it’s a simple example)
I’m still not sure what you’re asking, but it seems you have multiple
<a>s inside an<li>, and want to the hide just the one that was clicked on.Is this what you want?
EDIT: To only hide elements with a specific class, you can do this:
DEMO: http://jsfiddle.net/LTPpJ/