Im trying to call a jQuery inside a javaScript function, but it doesnt work, what I am doing wrong?
<script type="text/javascript" language="javascript">
function Test() {
$(document).ready(function () {
$("#pezz").animate({
left: '+=150px',
height: '+=20px',
width: '+=20px'
});
});
}
</script>
call from a method int the Bean
RequestContext.getCurrentInstance().execute("Test");
UPDATE:
As Gibberish suggested I change the Script to this:
<script type="text/javascript" language="javascript">
$(document).ready(function () {
Test();
});
function Test() {
$("#pezz").animate({
left: '+=150px',
height: '+=20px',
width: '+=20px'
});
}
</script>
But Works only once, Its supposed to work every time some condition is reached in the method, what canI do to fix this?
1 Answer 1
Restructure like this:
<script type="text/javascript" language="javascript">
$(document).ready(function () {
Test();
});
function Test() {
$("#pezz").animate({
left: '+=150px',
height: '+=20px',
width: '+=20px'
});
}
</script>
answered Jul 8, 2016 at 11:34
cssyphus
40.4k21 gold badges106 silver badges124 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
DedalusNine
thanks, It works, but only one time, in the method every time the user gives the wrong answer the image move. what can I do to fix this?
lang-js
document-readyevent handler