Advertisement

06.07.2008 at 11:44AM PDT, ID: 23466362
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Toggle CSS Style (height) Via JavaScript on Elements without an ID or Class

Asked by thyros in JavaScript, Hypertext Markup Language (HTML), Extensible HTML (XHTML)

Hi,

Would like to selectively toggle some elements styling via javascript, but these do not have direct ID's or classes.

Here is a real world example/scenario:

I have 6 content blocks made up of divs (no tables), 3 in a row spread over 2 rows, i.e.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Block 1 top left       |  |  Block 2 top center      |  | Block 3 top right       |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++  
| Block 4 bottom left |  | Block 5  bottom center |  | Block 6 bottom right |  
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

Each of these boxes has some text blurb in them, but I have applied a fixed height with an overflow:hidden; so that it displays with equal height on each row.

I would like to create a solution where clicking on the text blurb will toggle the current "height:6em;" style and change it to something like "height:12em;" so that the full text can be seen and read, but this should only affect the first row (block 1, 2, 3) or just the second row (block 4, 5, 6) depending on which block text the user clicked on.

One of the issues I have is that the bottom level element is just a 'p' tag with no id or class.  Please see the attached code snippet to see the sample html code for one of the block elements.  The parent ID element is the only unique id there for each of the 6 blocks.  I guess two javascript functions are required, one which affects the first three ID's and another which affects the last 3 ID's.

Any ideas?  please let me know if you need clarification.  Thanks.


(The element we want to apply the height changes to is the bottom level p element, i.e.  div.picktextbg p {height:12em;})Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
<div id="dp1tl">
	<!--  CONTENT ELEMENT, uid:530/list [begin] -->
		<a id="c530"/>
		<!--  Plugin inserted: [begin] -->
			
<div class="news_list_container">
 
	
		<div class="news_list_item">				
    		<div class="picktitlebg"><div class="picktitle"><a title="Sony DCR-DVD306 Handycam DVD Camcorder" target="_self" href="/dvd-camcorder.html">Sony DCR-DVD306 Handycam DVD Camcorder</a></div></div>
			<div class="news_list_image"><center><a title="Sony DCR-DVD306 Handycam DVD Camcorder" target="_self" href="/dvd-camcorder/"><img width="56" height="50" border="0" title="Sony DCR-DVD306 Handycam DVD Camcorder" alt="Sony DCR-DVD306" src="typo3temp/pics/f130deaff9.jpeg"/></a></center></div>
			<div class="picktextbg"><p>Today's pick is a handycam camcorder from Sony featuring Carl Zeiss optics, the DVD306 is one of the latest models which also offers very good value for money.</p></div>
			<div class="news_list_compriceimage">
				<center>
					<a href="http://www.example.com/broadband/"><img class="dpickcompare" alt="Compare Prices" src="fileadmin/img/compareprices.gif"/></a>
				</center>
			</div>	       
		</div>
			
		
</div>
 
		<!--  Plugin inserted: [end] -->
			
	<!--  CONTENT ELEMENT, uid:530/list [end] -->
		</div>
[+][-]06.07.2008 at 12:50PM PDT, ID: 21736616

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 12:56PM PDT, ID: 21736630

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 01:02PM PDT, ID: 21736637

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 02:11PM PDT, ID: 21736805

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 05:23AM PDT, ID: 21742592

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 05:40AM PDT, ID: 21742691

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 06:03AM PDT, ID: 21742813

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Hypertext Markup Language (HTML), Extensible HTML (XHTML)
Sign Up Now!
Solution Provided By: vibrazy
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628