• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Editing Query list selection click

Hi guys,

Basically I have this page:


The essential extras are list items, I now want to change them so as the user actually has to click the 'Click to add this product to your selection' button rather than just anywhere within the <li>

Is this possible?

  • 3
  • 3
1 Solution
Chris StanyonCommented:
In your code you are binding the click event to the LI. You need to change that to the image.

// $("#relatedexpress li").click(function(){ //remove this line
$("#relatedexpress .message img").click(function(){

Open in new window

Now the click will be bound to the button.

Inside your click() function your are currently referring to 'this' which is the element clicked. At the moment that's the LI, but with the above change will become the IMG, so you may need to change the code inside:

Instead of this:


Open in new window

You'll need this:

var clickedli = $(this).parents("li");

Open in new window

deanlee17Author Commented:
Hi Chris,

Thanks for the reply, I implemented those changes, no change tho?

Chris StanyonCommented:
There are changes. The click event is now bound to your img, so when you click on it your code runs. It puts a tick in the box, hides the button and submits your form.

You will need to change some of your CSS as well. Currently you're setting the cursor to the pointer:

//line 1534 of stylesheets2013c.css
#relatedexpress li { cursor:pointer; } <!--remove this

//Add this to stylesheets2013c.css
#relatedexpress li .message img { cursor:pointer; }

Open in new window

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

deanlee17Author Commented:
Thanks Chris, that works perfectly.

Just one last thing, I am going to put another image in there, how can I make our changes unique to just that one image?
Chris StanyonCommented:
Give it a class and then change the jQuery selector:

<img class="extrasButton" src="..." />

and your jQuery selector:

$("#relatedexpress .extrasButton").click(function()) {
deanlee17Author Commented:
Perfect, thanks a million
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now