javascript - jquery mutually exclusive click -


There are 3 divs with 2 possible image tags for each of my (active or inactive) I if activating a div If the click is done then the other divs should be set to inactive. How can I do this with img tags and what happens if the user is javascript disabled?

Do you mean something like this?

  & lt; Div class = "block" id = "block1" & gt; & Lt; Img src = 'inactive_block1.jpg' & gt; & Lt; / Div & gt; & Lt; Div class = "block" id = "block2" & gt; & Lt; Img src = 'inactive_block2.jpg' & gt; & Lt; / Div & gt; & Lt; Div class = "block" id = "block3" & gt; & Lt; Img src = 'inactive_block3.jpg' & gt; & Lt; / Div & gt; Like a library, JavaScript will look like this:  
  $ (function () {$ ('block'). Click (function (ARTR) ('IMG') ('IMG'). ARRR ('SRCR', 'Inactive_block 1.jpg'); $ ('# block2')., 'Inactive_block2.jpg'); $ ('# block3') ('Img') .tr ('src', 'deactivate_blok 3.jpg'); $ (this) .fund ('img'). 'Src', 'active_' + $ (this) .attr ('id ') +' .jpg ');});});  

With the above, if you have inactive_block1.jpg , inactive_block2.jpg , inactive_block3.jpg And active_block1.jpg , active_block2.jpg and active_block3.jpg you should get whatever you want.

Whether you are worth it or not, JavaScript does not require passive fallback, mostly depending on whether you expect a large amount of your audience to disable javascript.


Comments