Reputation: 361
var jobRole = $("select[name='location']").val();
$( "select[name='location']" )
.change(function () {
jobRole = $(this).val();
$('#hiddenList li').appendTo('.content');
$('.content li').not('+ jobRole').appendTo('#hiddenList');
$('#PBANK_searchResult').pajinate();
alert(jobRole);
});
If Edinburgh is select ".Edinburgh" appears as an alert ( I done this to check). However I was expeting that .Edinburgh would appear in the not() and resemble something like this:
$('.content li').not('.Edinburgh').appendTo('#hiddenList');
If I hardcord Edinburgh in to this the rest of the function works but I really need it to a variable depending on what is selected in the select box.
Thanks for your time
Upvotes: 1
Views: 72
Reputation: 41539
You're using jobRole
within the string selector - just a typo:
$('.content li').not('+ jobRole').appendTo('#hiddenList');
$('.content li').not(jobRole).appendTo('#hiddenList');
//Since you say the jobRole includes the '.' for the class selector
Upvotes: 1
Reputation: 133403
the variable already has the .
You need to use
$('.content li').not(jobRole).appendTo('#hiddenList');
Here jobRole
is a variable so you don't need that in quotes
Upvotes: 1
Reputation: 32581
You need to do like this to use a variable
$('.content li').not('.'+ jobRole).appendTo('#hiddenList');
// ^^^^^^
Update newInfo
$('.content li').not(jobRole).appendTo('#hiddenList');
// ^^^^^^ no quotes
Upvotes: 2