Reputation: 27
I have some code on our site that was working fine with jQuery 1.7.1, but now we've upgraded to 1.11.3 (for other coding reasons) the following code no longer appears to work:
jQuery('#CWformAddToCart select').change(function(){
jQuery('.skuOptionText span').removeClass('showOptionText');
var classList = jQuery.trim(jQuery('#availSkus').attr('value')).split(',');
if(classList.length == 1 && classList != ''){
jQuery('.skuOptionText span.' + classList).toggleClass'showOptionText');
}
});
This basically toggles the visibility of a span depending on the selection in a form select dropdown.
You can see it here: view source of site (use Chrome)
Lines 2125-2132 are the spans that get toggled between hidden & visible according to the select on lines 2147-2156. Though right now they are all stuck on hidden...
Any help is appreciated.
Upvotes: 0
Views: 47
Reputation: 207501
The code has a typo in it... toggleClass'show
. Missing the (
You should read value with .val()
not .attr("value")
And if you split a string into a array, it can not equal ""
. Guessing it should be if(classList.length == 1 && classList[0] != ''){
Upvotes: 3