2015-10-05 60 views
1

如果我刪除了我的jQuery鏈接工具提示懸停CSS背景工作正常,但我的jQuery功能不工作(顯然是因爲jquery鏈接被刪除)請看我的代碼....謝謝 `引導工具提示不能與我的jQuery功能

<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> 

回答

1

你不能src和內容相同script標籤

SRC
該屬性指定外部憑證的URI噸;這個 可以用來替代直接在 文檔中嵌入腳本。如果腳本元素具有指定的src屬性,則應在其標籤內不嵌入腳本。

<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> 
1

您不能<script>你想

第一關</script>的jQuery的lib腳本

<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> 
方式