Solved

jQuery hide show dt dd row

Posted on 2012-03-26
6
391 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

820 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