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?
This question is related to
jquery
Use find()
$(this).find(".subclass").css("visibility","visible");
Maybe something like:
$(".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");
})
What you are looking for is this:
$(".subclass", this).css("visibility","visible");
Add the this
after the class $(".subclass", this)
Source: Stackoverflow.com