0

How to get the form object?

I use this.box meaning sheet.box here, but the script produces an error. How do I get the sheet object in the sheet properties?

<div class="box">
    <form action=""></form>
</div>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
    var sheet={
        box: $('.box'),
        form: this.box.find('form') // TypeError: this.box is undefined
    }
</script>
melhosseiny
  • 9,992
  • 6
  • 31
  • 48
mingfish_004
  • 1,385
  • 2
  • 18
  • 26

2 Answers2

1

I guess what you need is a function:

form: function() {return this.box.find('form');}

Otherwise, you should be more specific.

Dek Dekku
  • 1,441
  • 11
  • 28
0

Old versions of Firefox (I tried Firefox 4 which warns but still accepts it) actually allowed you to do this:

var sheet = {
    box: #1= $('.box'),
    form: #1#.find('form')
}
Neil
  • 54,642
  • 8
  • 60
  • 72