Check which button has been clicked using jQuery -


How can I do this - using the if / else statement - check which button is clicked on ?
I am currently using this jQuery code:

  var nextBTN = $ ('. Carousel .next'); Var backBTN = $ ('. Carousel .back'); If (nextBTN.trigger ('click') == true) {/ * Next button has been clicked? * / Console.log ('Next BTN Click'); } Else if (backtBTN.trigger ('click') == true) {console.log ('backBTN clicked'); }  

HTML:

  & lt; Div class = "carousel" & gt; & Lt; Ul & gt; & Lt; Li class = "back" & gt; & Lt; Span & gt; Back & lt; / Span & gt; & Lt; / Li & gt; & Lt; Li class = "next" & gt; & Lt; Span & gt; Next & lt; / Span & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt;  

Thank you in advance.

Click on the link to see an example of work and you click on the li point in the work example. need to.

  $ (document) .ready (function () {$ ('. Carousel'). Find ("li" ".) Click (function (e) {var le = $ ( E.target); if (li.hasClass ("next")) {warning ("next") and if (li.hasClass ("back")) {warning ("back")}};}); < / Code> 


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -