How can I select a class from that object this
?
$(".class").click(function(){
$("this .subclass").css("visibility","visible");
})
I want to select a $(this+".subclass")
. How can I do this with Jquery?
Use $(this).find()
, or pass this in context, using jQuery context with selector.
Using $(this).find()
$(".class").click(function(){
$(this).find(".subclass").css("visibility","visible");
});
Using this
in context, $( selector, context )
, it will internally call find function, so better to use find on first place.
$(".class").click(function(){
$(".subclass", this).css("visibility","visible");
});
Maybe something like:
$(".subclass", this);
What you are looking for is this:
$(".subclass", this).css("visibility","visible");
Add the this
after the class $(".subclass", this)
if you need a performance trick use below:
$(".yourclass", this);
find() method makes a search everytime in selector.
Well using find is the best option here
just simply use like this
$(".class").click(function(){
$("this").find('.subclass').css("visibility","visible");
})
and if there are many classes with the same name class its always better to give the class name of parent class like this
$(".parent .class").click(function(){
$("this").find('.subclass').css("visibility","visible");
})