zwwcn

Just another WordPress.com site

javascript onclick event not working in chrome

The onclick event for select option is not triggered in chrome. We need to fire the onchange event on the select component.

<select class="select-one-group-select">
 <option class="select-one-group-option" value="option1">option 1</option>
 <option class="select-one-group-option"  value="option2">option 2</option>
 <option class="select-one-group-option"  value="option3">option 3</option>
</select>

This doesn’t work:

	$(".select-one-group-option").click(function() {
		showFilters(parseInt(this.value));
	});

 

This solve the problem:

	$(".select-one-group-select").change(function() {
		showFilters(parseInt(this.value));
	});

One response to “javascript onclick event not working in chrome

  1. outsourcedguru April 6, 2016 at 2:15 am

    I don’t think that click() was ever an event for the select element, to be honest. http://www.w3schools.com/tags/ref_eventattributes.asp

Leave a reply to outsourcedguru Cancel reply