Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  19] [ 2]  / answers: 1 / hits: 46005  / 13 Years ago, mon, november 14, 2011, 12:00:00

I have an ASP.NET application that renders multiple questions with the option to provide an explanation for the answers given.



<label for=[<%:count %>].AnswerExplanation_<%: i+1 %> id=[<%:count %>].toggleExplanation_<%: i+1 %>><strong>Add Explanation</strong></label>
<br /><br />
<div id=[<%:count %>].Explanation_<%: i+1 %>>
<textarea id=[<%:count %>].AnswerExplanation_<%: i+1 %> name=[<%:count %>].AnswerExplanation_<%: i+1 %> class=ckedit></textarea>
</div>


so you will have id's like [X].toggleExplanation_Y corresponding to [X].AnswerExplanation_Y



I am writing a javascript function to show/hide the AnswerExplanation divs, and was looking for a way to select every id containing toggleExplanation I should be able to get the rest from there.


More From » jquery

 Answers
51

Try using the attribute contains collector



$('label[id*=toggleExplanation]')

[#89133] Saturday, November 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kentrelle

Total Points: 333
Total Questions: 93
Total Answers: 95

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
;