javascript - Swapping an image onClick with jQuery from 4 buttons -


i've had through other questions , unable find solution. have 4 buttons , want them change colour of dress when click them using jquery. in dreamweaver have managed sort of working rather replacing image seems replace buttons, advice on i'm going wrong appreciated. created jsfiddle of works less, here is: http://jsfiddle.net/zd72f/

also sorry not linking fiddle properly, link i've added work.

<body style="margin:0 0 0 0;">     <div class="background">         <div id="index-dress">      </div> </body> 

thanks in advance help!

you need include jquery in fiddle changing src of image placed inside #index-dress div:

$('#index-dress img').attr('src'........ 

instead of images you're doing @ moment:

$('img').attr('src'........ 

final code should this:

$(document).ready(function () {     $('.buttons').click(function () {         $('#index-dress img').attr('src', "http://public.layar.com/customer_care/demos/fashion/htmldress/images/scarlet-dress-sized.png");     });     $('.navy').click(function () {         $('#index-dress img').attr('src', "http://public.layar.com/customer_care/demos/fashion/htmldress/images/navy-dress-sized.png");     });     $('.purple').click(function () {         $('#index-dress img').attr('src', "http://public.layar.com/customer_care/demos/fashion/htmldress/images/purple-dress-sized.png");     });     $('.yellow').click(function () {         $('#index-dress img').attr('src', "http://public.layar.com/customer_care/demos/fashion/htmldress/images/yellow-dress-sized.png");     }); }); 

updated fiddle


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -