Solved

jQuery hide show dt dd row

Posted on 2012-03-26
6
373 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now