Firstly, $.function
is not part of the jQuery API and will be undefined. I suspect you want to use the ready
event which is typically done like this:
$(document).ready(function ({
var temp = $("#form1");
foo(temp);
});
Secondly, $.$
is also not part of the jQuery API and so dataform.$("#ddd")
will be also undefined. Since you're trying to find a descendant element (and not a direct child element), I would recommend the find
method:
foo = function(dataform) {
dataform.find("#ddd").val() //?????
};
Also, as an aside, in the above code you are not doing anything with the value of #ddd
so there won't be any discernible actions visible on the page when it successfully executes.
Finally, assuming your markup is valid and each id
attribute is unique, using .find
to find an element by id is less efficient than simply searching by id
(i.e., $('#ddd').val()
). Mind you, this obviously defeats the purpose of passing $("#form1")
as a function parameter but it's more efficient (in terms of querying the DOM) and it makes me wonder what you are trying to accomplish. If you can update your question with the overall goal, we may be able to better assist you.