I am trying to dynamically create a key in a JavaScript object with a jQuery selector:
{
$("form").children("input[type=hidden]").attr("name"): $("form").children("input[type=hidden]").val()
}
This is breaking though. Is it possible to dynamically create a key this way?
You can do it in two statements :
I’d personally write it like this to avoid recreating the jQuery set:
Note also that this only makes sense if the jQuery set contains exactly one element.