0

im new to opencart and javascript. I am trying to target a textarea option associated with a product in opencart so i can implement some javascript code. At the moment i just have an alert box that appears when you type in the textarea, but it doesnt seem to work. My question, is it possible to target these option textareas that are generated by the opencart back end? Below is a snippet of javascript code that seems to work on other textareas but not on option textareas.

<script type="text/javascript"><!--
$(document).ready(function() {

    $('.options').keyup(function() {
        alert('test');
    });

});
//--></script>
2
  • My colleague Adrian just cleaned the code a small bit, but the question still stands. Mar 21, 2014 at 11:08
  • Try $('.options textarea').
    – shadyyx
    Mar 21, 2014 at 12:45

1 Answer 1

0

Append following snippet into product.tpl, before the last line <?php echo $footer; ?>

<script type="text/javascript"><!--
$(document).ready(function() {
     $(".options textarea").keyup( function() {
        alert('test');
    });
});
//--></script> 

Whenever you input any characters, there will an alert coming out.

Notes: maybe you hope one even whenever you mouse up, you can bind mouseup event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.