I’m wondering where I would put code to take a variable from PHP (used in numbering classes) and store it in a variable that jQuery can access?
Here is an example:
$(".object1-22").hover(function(e){
$(".object2-22").show();
}, function(e) {
$(".object2-22").hide();
});
So in my code, I have two objects. When you hover over the 22nd instance of object1, I want it to only display the 22nd instance of object2.
How could I perform this task?
If you create IDs for your objects (“22nd instance of object2”), use HTML IDs, not CSS classes.
I guess you want the same behavior for all the objects, so do not write separate event handlers for each of them. Use a common CSS class (
object1andobject2) and individual IDs (object1-22,object2-22)Consider
You could even link the related elements beforehand.
That being said, this is a question for StackOverflow, unfortunately I do not have enough rep here to flag it accordingly.