Nathan McKaskle Nathan McKaskle - 2 years ago 81
jQuery Question

('...').each not a valid function for core mvc with jquery bundle

Reposting this because I cannot find any answer that doesn't involve using Google's bundle or something else. Please tell me if I'm missing any detail so I'll add it. I have the whole jquery bundle included with VS referenced at the top of my _Layout...


Here's the BundleConfig.cs

public static void RegisterBundles(BundleCollection bundles)
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(

bundles.Add(new StyleBundle("~/Content/css").Include(

...but it is still telling me in this case that
is not a function. What I'm missing or need to refer to the layout or BundleConfig? Why isn't
a function that is a part of the jquery bundle that comes with Visual Studio 2017?

@Html.ListBox("Groups", null, new { size = 10, style = "width : 350px; max-width : 500px;", id = "grouplist" })

The whole context of my jquery:

$('#savegroups').click(function () {
var groupId = $('#groupId').val();
var list = [];
('#grouplist').each(function (item) {
list.append('{"groupId":"' + groupId + '","groupName":"' + item.value +'"}');
type: "POST",
url: "/GroupCategories/EditGroups",
data: JSON.stringify(list),


1:230 Uncaught TypeError: "#grouplist".each is not a function
at HTMLInputElement.<anonymous> (1:230)
at HTMLInputElement.dispatch (jquery:1)
at HTMLInputElement.y.handle (jquery:1)

Answer Source

Looks like you are missing the jquery selector..


should be

$('#grouplist option')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download