-2

I'm trying to learn JQuery and I got this error. Invalid left-hand side in assignment I'm trying to point the selector without using any events function.

        let a = $("td:contains('"+ word +"')") = function(){
            $(this).closest('tr').hide();
            $(this).closest('tr').wrap('<hidden>');
            state = true;
        }         
        a();
cigien
  • 57,834
  • 11
  • 73
  • 112
  • 2
    What are you trying to do? What is expected output – navnath Oct 09 '21 at 14:35
  • 1
    *"point the selector without using any events function"* - What does that even mean? If your goal is for `a` to be a function, what is the intent of having `$("td:contains('"+ word +"')")` there? It's not really clear what you're trying to do. – David Oct 09 '21 at 14:38
  • 2
    Please don't vandalize your posts. By posting on the Stack Exchange network, you've granted a non-revocable right, under the [CC BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/), for Stack Exchange to distribute that content (i.e. regardless of your future choices). By Stack Exchange policy, the non-vandalized version of the post is the one which is distributed, and thus, any vandalism will be reverted. If you want to know more about deleting a post please see: [How does deleting work?](/help/what-to-do-instead-of-deleting-question). – cigien Oct 09 '21 at 14:52

1 Answers1

0

The error likely lies in this part:

$("...")=function(){...}

$("...") already returns an object, so you can't assign a function() to it.

From your code, I guess what you want may be this:

let a=(function(){...}).bind($("..."));

a();
Passerby
  • 9,715
  • 2
  • 33
  • 50