Hellp with Jquery Argument / Statement
I have a custom piece of script that i am trying to modify. The function of this is to display a Pricing Table. One product may have hundreds of pricing tables depending on what attributes are chosen. As it stands, it will only show one at a time and only if attributes are selected.
- /**
- * VARIABLE PRODUCT PRICING TABLE
- */
- function rp_wcdpd_switch_variable_pricing_tables(element_id) {
- jQuery('.rp_wcdpd_pricing_table_variation').hide();
- jQuery(element_id).show();
- }
- if (jQuery('.rp_wcdpd_pricing_table_variation').length) {
- jQuery('input:hidden[name="variation_id"]').each(function() {
- rp_wcdpd_switch_variable_pricing_tables('#rp_wcdpd_pricing_table_variation_' + jQuery(this).val());
- jQuery(this).change(function() {
- rp_wcdpd_switch_variable_pricing_tables('#rp_wcdpd_pricing_table_variation_' + jQuery(this).val());
- });
- });
- }
I then modofied this to allow the first pricing table to display before anything is selected. This works, but the problem is that when a user selects an attribute is shows two tables instead of the attribute table replacing the first default table.
This is what was added to show the first table as default.
- jQuery('.rp_wcdpd_pricing_table_variation').first().show();
So my question is how can i write this so that the default (First table is hidden only when an attribute is selected) and replaced by the new table of that attribute.