javascript - JS click event depending on div width -


I am trying to resize two disks with one display if a query has a query. If div # slide_3_1 is clicked with 100% and # arrow_right_3

code> 100% wide.

When I click # arrow_right_3 nothing happens any thoughts? Thanks!

  var $ div_width = $ ('# slide_3_1'). Attr ('width'); $ (Document) .ready (function () {$ ("# arrow_right_3"). Click (function () {if ($ div_width> 0) {$ ("# slide_3_1"). CSS ('width', '0px'); $ ("# Slide_3_2"). CSS ('width', '100%');}});});  

HTML:

  & lt; Div id = "section_3" square = "section" & gt; & Lt; Div class = "arrow_left" id = "arrow_left_3" & gt; Arrow left & lt; / Div & gt; & Lt; Div class = "arrow_right" id = "arrow_right_3" & gt; Sharp right & lt; / Div & gt; & Lt; Div id = "slide_3_1" square = "slide" & gt; & Lt; / Div & gt; & Lt; Div id = "slide_3_2" square = "slide" & gt; & Lt; / Div & gt; & Lt; Div id = "slide_3_3" square = "slide" & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

There is a typo in your code, on the first line it should be '$' Div_width ' .

In addition, you should get the width using '$ div.width ()'. It will always return the width, even if the element has no width attributes.


Comments