Can i find/filter element after $(this)?
in jquery we can find inner class or something else with
$("#id xxxxxx")
xx... can be anything.
But i am taking element by this like below:
$(".something").bin开发者_StackOverflowd("click",function(){
$(this).find("......
});
and want to take inner element something like : $(this + " .divClassNameOrFilter")
I can take the element with $(this).find(".divClassNameOrFilter)
But after i found something that will be an array and i can't continue with
$(this).find(".divClassNameOrFilter).css(.....
I have to take the first element with [0]
and wrap it again with $(...)
like that:
$($(this).find(".divClassNameOrFilter)[0]).css(.....
Is there any way not to do like i said above?
You can use .eq()
like this:
$(this).find(".divClassNameOrFilter").eq(0).css(...);
Or use :first
, like this:
$(this).find(".divClassNameOrFilter:first").css(...);
As an aside, there are other filter functions and selectors as well.
That should be possible using .first()
:
$(this).find(".divClassNameOrFilter").first().css(.....
精彩评论