Trying to figure out how to apply a wildcard concept to something while applying where not.
Right now I have $('.zm_name[rel!="'+keyed+'"]').parent().hide(); which will hide everything not exactly matching the keyed value I am looking for, this works fine. However it only works when the keyed value is exact. So I am looking to have it so its like keyed* but anything not equal to the beginning of the string hide.
I tried $('.zm_name[rel^!="'+keyed+'"]').parent().hide(); but only get a syntax error, I browsed through the jquery selectors section of the api, and can't seem to find what I am looking for exactly. So I am wondering is there any actual way of combining this method?
Try this
$('.zm_name:not(.zm_name[rel^="'+keyed+'"])').parent().hide();
//OR
$('.zm_name:not([rel^="'+keyed+'"])').parent().hide();
DEMO
I usually stay away from very long selectors because they can be confusing and redundant. Try using the filter method:
$('.zm_name').filter(function(){
return !(new RegExp('^'+ keyed)).test(this.rel);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With