You're probably assigning to searchbox before the #searchinput element
exists:
<head>
  <script>
    $.searchfunction = { searchbox: $('#searchinput) } // empty jQuery
object because <body> hasn't been created yet
  </script>
</head>
<body>
  <div id="searchinput"></div>
  <script>
    console.log ($('#searchinput')); // one element in jQuery object
    console.log ($.searchfunction.searchbox); // no elements--you
aren't re-running the query, just using the failed one from earlier
  </script>
</body>

Solution:
  put the initial assignment in a $(document).ready function, so it
won't be assigned until the entire DOM is available.

On Apr 3, 7:19 pm, ScottBruin <[EMAIL PROTECTED]> wrote:
> Please pardon my poor understanding of javascript basics:
>
> I've been using the following method to create an object array of
> variables:
>
>         $.searchfunction = {
>                 searchbox: $('#searchinput'),
>                 url: 'http://localhost',
>                 targetdiv: $('#results'),
>                 specifierobj: {},
>                 keyboardid: '#keyboard'
>         };
>
> I'm having trouble with getting the value of
> $.searchfunction.searchbox. I'm calling it in the following manner:
>
>         var curval = $.searchfunction.searchbox.val();
>
> This isn't working--I tested this attempt with val() in Firebug and it
> does not work. I've noticed that if I type in $('#searchinput') in
> Firebug, the object is different than $.searchfunction.searchbox.
>
> Respectively,
>
>         >>> $.searchfunction.searchbox;
>         Object length=0 context=document selector=#searchinput
>
>         >>> $('#searchinput');
>         Object 0=input#searchinput length=1 context=document
>
> I know there are jQuery objects and other types of objects, so I am
> assuming it is a problem with this but I don't understand why the
> variable does not store the #searchinput in the same manner.
>
> Thanks for any help.

Reply via email to