Solved

jQuery hide show dt dd row

Posted on 2012-03-26
6
403 Views
Last Modified: 2012-03-26
What would be the preferred way to hide or show the dt and dd for discount?

<dl class="total-line">
                    <dt>Subtotal:</dt><dd>$211.55</dd>
                    <dt>Shipping:</dt><dd>$5.55</dd>
                    <dt>Tax:</dt><dd>$0</dd>
                    <dt>Discount:</dt><dd>-$5.55</dd>
                    <dt>Grand Total:</dt><dd>$211.55</dd>
 </dl>
0
Comment
Question by:JRockFL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 37765629
//to hide
$(".total-line dt").last().hide();
$(".total-line dd").last().hide();

//to show
$(".total-line dt").last().show();
$(".total-line dd").last().show();
0
 
LVL 82

Expert Comment

by:leakim971
ID: 37765636
what about :
$( ".total-line dd:eq(" + $("dt:contains('Discount')").hide().index(".total-line dt") + ")" ).hide();

Open in new window

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37765648
or even

//to hide
$(".total-line dt").last().hide().next("dd").hide();

//to show
$(".total-line dt").last().show().next("dd").show();
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 500 total points
ID: 37765665
Sorry, i was working on last item rather than 'Discount' one

make it

//to hide
$(".total-line dt").last().prev("dt").hide().next("dd").hide();

//to show
$(".total-line dt").last().prev("dt").show().next("dd").show();

if the order of the items is not fixed, then
$(".total-line dt").each(function(){
  if ($(this).html().indexOf("Discount") != -1)
  {
     $(this).show(); \\or use hide() for hiding
     $(this).next().show(); \\or use hide() for hiding
  }
});
0
 
LVL 8

Author Comment

by:JRockFL
ID: 37765803
Could I just add a id to the discount dt and dd?
0
 
LVL 8

Author Comment

by:JRockFL
ID: 37765965
nevermind, this works great.

f the order of the items is not fixed, then
$(".total-line dt").each(function(){
  if ($(this).html().indexOf("Discount") != -1)
  {
     $(this).show(); \\or use hide() for hiding
     $(this).next().show(); \\or use hide() for hiding
  }
});
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question