2

I've an error with JQuery on the first line of :

    $('select#operation option:selected').each(function() {
        parent_value = $(this).val();
    });

I got an other error with /jquery-1.5.1.js on line 3539 :

        if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {

Everything i working on FF, Chrome and Safari but i got errors on IE.

The errors are : "Object doesn’t support this property or method"

2 Answers2

5

Sizzle (the library jQuery uses behind the scenes to select elements), does not function well if you add your own methods to Object.prototype; which, from your earlier question today, you are doing!

As I commented in your previous question, adding members to Object.prototype is highly frowned upon.... now you can see why :). Instead of adding the methods to the Object prototype, simply define them as functions.

Community
  • 1
  • 1
Matt
  • 74,352
  • 26
  • 153
  • 180
  • But for big projects, you may need to add members to Object.prototype, and no where in docs does it say it is wrong. So why should the script crash just because of that. – JohnMerlino Aug 19 '14 at 02:27
  • @JohnMerlino: See http://stackoverflow.com/a/3833445/444991. It's not **wrong**; the language *lets* you do it. It's just strongly recommended you don't do it. You shouldn't modify objects you don't own. If you're working on a big project, define your own namespace, and add methods to that, not `Object.prototype`. Imagine if you used several libraries in your big project; what happens if one of them also (ab)used `Object.prototype`, and added a method of the same name (but different functionality); one of the implementations is now going to break! – Matt Aug 19 '14 at 07:55
  • wow, this was super useful, I would have never thought that this can cause such a bug. – gsanta Nov 04 '15 at 15:09
0

Not a direct answer to your problem but I think you would be better doing this:

parent_value = $('#operation').val();
Richard Dalton
  • 35,513
  • 6
  • 73
  • 91