1

If i removed my jquery link tooltip hover css background working fine but my jquery function not working ( obviously because of jquery link was removed) please look my code.... thanks `

  <div class="col-sm-6">
    <input type="text" id="id_part_pay"  value="<?php echo $listing['part_pay'];?>"   class="textbox" name="id_part_pay" <?php if($checked)echo 'style="display: block"'; else echo 'style="display: none"';?> />
    <a href="" class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Hooray!"></a>
    <span class="ft-s12"></span>
  </div>  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">    
    $(function() {
        $("#id_part_pay").next('span').hide(); 
        $("#id_part_pay").keyup(function() {
        var input = $(this).val();
        var v = input % 10;
        var span = $(this).next('span'); 
        if (v !== 0) {
        span.text("Enter Percentage in multiple of 10").show(); 
        return;
        }
        if (input < 20 || input > 100) {
         span.text("Percentage should be between 20 - 100").show();
        return;
        }
        span.text('').hide();//Clear Text and hide
       });
    });
  </script>

2 Answers 2

1

You can't have src and content for the same script tag

src
This attribute specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a document. If a script element has a src attribute specified, it should not have a script embedded inside its tags.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
    $(function () {
        $("#id_part_pay").next('span').hide();
        $("#id_part_pay").keyup(function () {
            var input = $(this).val();
            var v = input % 10;
            var span = $(this).next('span');
            if (v !== 0) {
                span.text("Enter Percentage in multiple of 10").show();
                return;
            }
            if (input < 20 || input > 100) {
                span.text("Percentage should be between 20 - 100").show();
                return;
            }
            span.text('').hide(); //Clear Text and hide
        });
    });
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

You can't include <script> the way you are trying

first close </script> jQuery lib script

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

and then write custom script

<script>
$(function () {
    $("#id_part_pay").next('span').hide();
    $("#id_part_pay").keyup(function () {
        var input = $(this).val();
        var v = input % 10;
        var span = $(this).next('span');
        if (v !== 0) {
            span.text("Enter Percentage in multiple of 10").show();
            return;
        }
        if (input < 20 || input > 100) {
            span.text("Percentage should be between 20 - 100").show();
            return;
        }
        span.text('').hide(); //Clear Text and hide
    });
});
</script>

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.