V
V
Vasily Petrov2018-02-07 20:31:58
JavaScript
Vasily Petrov, 2018-02-07 20:31:58

I don't understand what's wrong? Error Invalid left-hand side in assignment?

There is this code:

$('.far .bar').click(function(e){
        e.preventDefault(); // нужно для остального куска кода
        var qwe = $(this).siblings('a');
        $(qwe) = $('.far .bar a').attr('href');
        alert(qwe);
});

There are many identical elements on the page, when you click on one of them, its value is taken. More precisely, this is how it was intended, but the error Invalid left-hand side in assignment comes out? to this line $(qwe) = $('.far .bar a').attr('href');

What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-02-07
@mbpig

$(qwe) = $('.far .bar a').attr('href');
The problem is in this line. It is not clear what exactly you were trying to do, but it turned out to be an erroneous construction, where you are trying to assign one jQuery object to another. It doesn't work like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question