<div class="main">
<a title="here" href="http://google.com">google.com</a>
<a title="sss" href="www.sss.com">sss</a>
<a title="sss" href="www.sss.com">sss</a>
<a title="sss" href="www.sss.com">sss</a>
<a class="click" href="#">check site</a>
</div>
<div class="main">
<a title="here" href="http://stackoverflow">stackoverflow</a>
<a title="sss" href="www.sss.com">sss</a>
<a title="sss" href="www.sss.com">sss</a>
<a title="sss" href="www.sss.com">sss</a>
<a class="click" href="#">check site</a>
</div>
<div class="main">
<a title="here" href="http://cnn.com">cnn.com</a>
<a title="sss" href="www.sss.com">sss</a>
<a title="sss" href="www.sss.com">sss</a>
<a title="sss" href="www.sss.com">sss</a>
<a class="click" href="#">check site</a>
</div>
i wrote:
$(".click").click(function(){
alert($(this).parent().filter("[title=here]").attr('href'));
})
but this show me undefined. How can i get current site from current DIV?
The
filtermethod filters out specific items from a result, you want to use thefindmethod to find children of the element in the result:The
filtermethod would be used if you have all the childred and want to keep a specific one. Example: