开发者

How to change selected item in dropdown via clicking on an image (jquery)

开发者 https://www.devze.com 2023-03-12 20:38 出处:网络
I am using magento, but am far from jquery/javascript I have a list of images that i want to be able to click and change the corresponding dropdown list selection.

I am using magento, but am far from jquery/javascript

I have a list of images that i want to be able to click and change the corresponding dropdown list selection.

I can have it set up so that select name/value or option value can be attached to each image that 开发者_JAVA百科corresponds either using class or id. So i just need the basic jquery to input

thanks a million


Say the id of the image is the value of the dropdown item.

$('img').click(function() { 
    $('#dropdown').val($(this).attr('id'));
});

JsFiddle Example

0

精彩评论

暂无评论...
验证码 换一张
取 消