I have a WP Blog with a few DIVs generated through PHP loops. I would like to be able to show additional about a DIV when someone clicks on it.
The code looks like this:
<div class="story item-1">
<div class="story item-2">
<div class="story item-3">
<div class="story item-4">
(etc. Could be any number of these.)
Clicking on one of the items above should make one of the following appear:
<div class="data preview-1">
<div class="data preview-2">
<div class="data preview-3">
<div class="data preview-4">
I'm doing the following:
$('.story').click( function() {
var getNum = jQuery(this).attr('class');
alert('hi ' + getNum);
});
But how do extract the "number" value (1,2,3,4,etc.) of the item I just clicked into a variable? If I can get that into a variable such as "num" I can then easily use jQuery .hide and .show to perform actions. What I have so far gets the entire class value. Just need the number from the second class.
I'd appreciate any help! Thanks!