0

I have added one script in the form page which is,

<script type="text/javascript">
$(document).ready(function(){
$('.removeOnFocus').each(function()
{
    this.data = new Object(); //TODO don't overwrite previous data
    this.data.value = this.value;

    $(this).focus(function(){
        if (this.value == this.data.value)
            this.value = '';
    });
    $(this).blur(function(){
        if (this.value == '')
            this.value = this.data.value;
    });
});
});
</script>

To make this script working, I have added <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> in the same page. Its working fine but other contents in the page getting overlapping. How to avoid this and have to make this script?

2
  • Try to put your script in the footer of the page and see if it works fine.
    – Ciprian
    Commented Feb 21, 2018 at 7:28
  • Its not working. Whether I need to add the supporting script link in same page or without adding it will work? Commented Feb 21, 2018 at 7:32

1 Answer 1

0

Your script is a Jquery script : so you have to include it if you want your script to work.

If you don't want to include Jquery, you will have to rewrite your script using Prototype.

Finally, if you prefer to use JQuery, there will be a conflict between Jquery and Prototype for the symbol $ : try to replace $ by jQuery in your script.

To go further, you may want to try JQuery NoConflict .

0

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.