Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace / substitute a jQuery target

Tags:

jquery

I am trying to replace/substitute one of the jQuery targets below (not the HTML element), depending on which language is selected by the user.

For example, if user chooses English as language, I want to remove #English target, but keep the others (i.e. #Spanish, #German).

How can I do this?

 $( "#English, #Spanish, #German").click function { blah, blah, blah };
like image 720
Rob Myrick Avatar asked Jan 29 '26 11:01

Rob Myrick


2 Answers

Looks like you want to trigger the handler for an element only once, in that case use .one()

$( "#English, #Spanish, #German").one('click', function(){
})
like image 138
Arun P Johny Avatar answered Feb 01 '26 03:02

Arun P Johny


Unbind the id click event

$("#English, #Spanish, #German").click( function(){

    $(this).unbind('click');

});
like image 22
heymega Avatar answered Feb 01 '26 02:02

heymega



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!