I want to bind all li except the last using jQuery. whether it is possible to do this in one line, I tried to do this without any success.
$('#elementName li').on('click', someFunction); $('#elementName li:last-child').off('click');
?
You can use the .not()c selector :lastto filter the last element:
.not()
:last
$('#elementName li').not(':last').on('click', someFunction);
or
$('#elementName li:not(:last)').on('click', someFunction);
You can use : not () :
What about
$('#elementName li') .not($('#elementName li:last-child')) .on('click', someFunction);
You should use something like
$('#elementName li:not(:last-child)').on('click', yourFunc);
Source: https://habr.com/ru/post/1570878/More articles:how to create another session on url based on nodejs? - node.jssun / io / MalformedInputException when trying to remotely connect to a JMS queue on a web page - websphereWicket - Stale Page Exception - how to debug? - javaHow to solve sun / io / MalformedInputException problem when searching for JNDI on remote WebSphere - javaC ++ inherits a function with different default argument values - c ++How to create a random three-dimensional matrix? - matrixIs `using namespace std :: placeholders' inappropriate? - c ++Why does the GitLab Graph show only commits and not Add / Removes? - gituiimageview animation stops when user touches screen - iosRestsharp - XElement Property Exception - restsharpAll Articles