javascript - Select a Child Object -
my experience javascript , jquery null, so...
i'm trying rotate object (div_sheet_item), , store actual rotation inside hidden input called "rotation".
i can't value of input calculate angle, , don't have idea why.
here's code:
javascript
$(document).ready(function() { $('.div_sheet_item_rotate').click(function() { var rotation = $(this).parent().find('rotation').val(); rotation += 90; $(this).parent().rotate(rotation); }); }); html
<li class="div_sheet_item" style="width: 330px; height: 230px;"> <div class="div_sheet_item_rotate"><img src="img/ico_rotate.png"/></div> <input type="hidden" name="rotation" value="0" /> </li> <li class="div_sheet_item" style="width: 330px; height: 230px;"> <div class="div_sheet_item_rotate"><img src="img/ico_rotate.png"/></div> <input type="hidden" name="rotation" value="0" /> </li> <li class="div_sheet_item" style="width: 330px; height: 230px;"> <div class="div_sheet_item_rotate"><img src="img/ico_rotate.png"/></div> <input type="hidden" name="rotation" value="0" /> </li> any great.
thanks
jquery .find() function takes selector argument. find input name, should use attribute equals selector:
parent().find('[name="rotation"]') but better way assign class rotation input, , select class:
<input type="hidden" name="rotation" class="rotation" value="0" /> parent().find('.rotation')
Comments
Post a Comment