Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change a css style for 'this' class using jquery?

I have a list of images that each are tied to a class.

var hoverList = this.hoverable.getAllList() //this gets the list.

on mouseover of the images, I want a block of text in a different area, but shares a class, to display. I call

hoverList.mouseover(this.hoverable.displayTheDeets)

and it runs

displayTheDeets: function(){
    big=$(".project-details")
    thisClass=$(this).attr("class")
    console.log(thisClass)
    //$(big).find(thisClass).css("display","")
    $(big).find(thisClass).css("display", "block")
    //$(big > thisClass).css("display","block")
}

From the console, if I run the literal command

$(".project-details").find(".code-fusion")

it returns the element I want. And I can change the display with no problem.

I think my problem is with thisClass. Any thoughts would be appreciated.

like image 618
notthehoff Avatar asked Jan 11 '23 10:01

notthehoff


1 Answers

Try,

big.find('.' + thisClass).css("display", "block");

or simply

big.find('.' + thisClass).show();

Please note that .attr('class') would return the class being used for the particular element, and it wont return the class name in the format of selector.

Additional Note: And in sometimes if you have more than one class set with that particular element then it would make the selector as invalid like $('.class1 class2 class3')

like image 157
Rajaprabhu Aravindasamy Avatar answered Jan 19 '23 06:01

Rajaprabhu Aravindasamy