Reputation: 4009
I'm trying to select a data attributes value that has a space or a certain character in it but it doesn't like it very much. Below is the code that I have working for one worded attribute values.
$('div[data-roomtype='+$(this).data('roomtype')+']').animate({opacity:0.1},100);
And I have also put together a very simplified fiddle (http://jsfiddle.net/Tse6k/2/) of what I'm hoping to achieve. Is there an easy solution to this? Any help or advice would be much appreciated.
Upvotes: 4
Views: 7852
Reputation: 145468
Quote the value in the selector:
// ------------------v -------------------------------v
$('div[data-roomtype="' + $(this).data('roomtype') + '"]'). ...
DEMO: http://jsfiddle.net/Tse6k/3/
Upvotes: 18