-6

All links whose href's begin with https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2

add the following attribute:

onclick="return EJEJC_lc(this);

I've only got this far but i don't know how to add the onlick function to it

$("a[href$='https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2'].") 
Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
David
  • 39
  • 5
  • 2
    That's great! What have you tried so far? – esqew Nov 02 '18 at 19:11
  • See jQuery's [Attribute Starts With Selector](https://api.jquery.com/attribute-starts-with-selector/). – showdev Nov 02 '18 at 19:13
  • `$("a[href$='https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2'].")` ive only got that far but i dont know how to add the onlick function to it – David Nov 02 '18 at 19:13
  • See jQuery's [`click()`](https://api.jquery.com/click/) or [`on()`](http://api.jquery.com/on/). – showdev Nov 02 '18 at 19:16
  • `$("a[href$='https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2'].").click(function() { onclick = "return EJEJC_lc(this)"; });` So it would be something like this? – David Nov 02 '18 at 19:18
  • @DavidVerduzco no. See my answer below for the correct syntax. – Cory Fail Nov 02 '18 at 19:20

1 Answers1

1

You just needed to add the on() method.

http://api.jquery.com/on/

$('a[href^="https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2"]').on("click", function(){ 
  EJEJC_lc(this);
});
Cory Fail
  • 1,070
  • 8
  • 26