toolman
September 18, 2017, 10:04am
1
Hi there,
I have the following markup:
<div class="wtrShtTrainerStream wtrTwoCols clearfix">
<div class="wtrSht wtrShtTrainer ">
<div class="wtrShtTrainerMeta ">
<div class="wtrShtTrainerMetaName wtrShtTrainerAnimate">
<h5 class="wtrShtTrainerMetaNameHeadline wtrShtTrainerAnimate">NAME 1</h5>
</div>
</div>
</div>
<div class="wtrSht wtrShtTrainer wtrShtTrainerLastInRow">
<div class="wtrShtTrainerMeta ">
<div class="wtrShtTrainerMetaName wtrShtTrainerAnimate">
<h5 class="wtrShtTrainerMetaNameHeadline wtrShtTrainerAnimate">NAME 2</h5>
</div>
</div>
</div>
</div>
Is there a way I can give the <div>
with the class of “wtrShtTrainer” an ID based on the parent class “wtrShtTrainerStream” so I can then target them with other jQuery?
Thanks
Why does your code need seven div elements
to display just two words of content?
You do not have a Javascript problem, what you
do have is a semantic HTML problem.
coothead
I also doubt that you’re down to h5 for the headings.
toolman:
wtrShtTrainer
Why can’t you use a class selector with jQuery?
var trainerDivs = $(".wtrShtTrainer");
toolman
September 18, 2017, 11:03am
5
The code is being output by a Wordpress plugin that I do t have access to. I’m trying to give the div with the class “wtrShtTrainer” an ID
var trainerDivs = $(".wtrShtTrainer");
var trainderDiv = trainerDivs.get(0);
trainderDiv.id = "wtrShtTrainerID";
You can now use jQuery(“#wtrShtTrainerID ”) to reference that id.
toolman:
Thanks Paul, it worked
Wordpress and jQuery: 2 - coothead and sematic HTML: 0 .
1 Like
system
Closed
December 18, 2017, 6:22pm
9
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.